@dev-dudu-0515/panasuri 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/tests/index.test.d.ts +2 -0
- package/dist/tests/index.test.d.ts.map +1 -0
- package/dist/tests/index.test.js +38 -0
- package/dist/tests/index.test.js.map +1 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Elvin Aquiatan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# panasuri - Reactive Zod Validation Helper for ArrowJS
|
|
2
|
+
|
|
3
|
+
A lightweight validation helper built on top of **Zod** that makes form validation simple and reactive.
|
|
4
|
+
|
|
5
|
+
It provides:
|
|
6
|
+
|
|
7
|
+
- ⚡ Built for ArrowJS reactive state
|
|
8
|
+
- ✅ Full form validation
|
|
9
|
+
- ✅ Field-level validation
|
|
10
|
+
- 🔄 Reactive error updates
|
|
11
|
+
- 🪶 Lightweight and dependency-free (except Zod)
|
|
12
|
+
- 🎯 Type-safe with TypeScript
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install zod
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then import the helper.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createValidator } from "@lib/zod";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Basic Usage
|
|
31
|
+
|
|
32
|
+
Create your Zod schema.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { z } from "zod";
|
|
36
|
+
|
|
37
|
+
export const LoginSchema = z.object({
|
|
38
|
+
username: z
|
|
39
|
+
.string()
|
|
40
|
+
.min(1, "Username is required"),
|
|
41
|
+
|
|
42
|
+
password: z
|
|
43
|
+
.string()
|
|
44
|
+
.min(8, "Password must be at least 8 characters"),
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Initialize the validator.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const { errors, isValid, validateField } = createValidator(
|
|
52
|
+
input,
|
|
53
|
+
LoginSchema,
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
### `createValidator(data, schema)`
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
|
|
65
|
+
| Property | Description |
|
|
66
|
+
|----------|-------------|
|
|
67
|
+
| `errors` | Reactive object containing validation errors. |
|
|
68
|
+
| `isValid()` | Validates the entire form and returns `true` or `false`. |
|
|
69
|
+
| `validateField(field)` | Validates a single field. |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Validating a Field
|
|
74
|
+
|
|
75
|
+
Call `validateField()` whenever a field changes or loses focus.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
validateField("username");
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Example:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
<input
|
|
85
|
+
@input=${(e: Event) => {
|
|
86
|
+
input.username = (e.target as HTMLInputElement).value;
|
|
87
|
+
|
|
88
|
+
if (touched.username) {
|
|
89
|
+
validateField("username");
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
@blur=${() => validateField("username")}
|
|
93
|
+
/>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Displaying Validation Errors
|
|
99
|
+
|
|
100
|
+
The `errors` object contains an array of messages for each field.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
errors.username
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Example:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
<div>
|
|
110
|
+
${() =>
|
|
111
|
+
errors?.username?.map(
|
|
112
|
+
(error) => html`
|
|
113
|
+
<div class="text-error">
|
|
114
|
+
${error}
|
|
115
|
+
</div>
|
|
116
|
+
`,
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Validating the Entire Form
|
|
124
|
+
|
|
125
|
+
Use `isValid()` before submitting.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const submit = () => {
|
|
129
|
+
if (!isValid()) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Continue with form submission
|
|
134
|
+
};
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Complete Example
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const { errors, isValid, validateField } = createValidator(
|
|
143
|
+
input,
|
|
144
|
+
LoginSchema,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
<input
|
|
148
|
+
id="login_username"
|
|
149
|
+
type="text"
|
|
150
|
+
.value=${() => input.username}
|
|
151
|
+
@input=${(e: Event) => {
|
|
152
|
+
input.username = (e.target as HTMLInputElement).value;
|
|
153
|
+
|
|
154
|
+
if (touched.username) {
|
|
155
|
+
validateField("username");
|
|
156
|
+
}
|
|
157
|
+
}}
|
|
158
|
+
@focus=${() => {
|
|
159
|
+
touched.username = true;
|
|
160
|
+
}}
|
|
161
|
+
@blur=${() => {
|
|
162
|
+
validateField("username");
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
<div>
|
|
167
|
+
${() =>
|
|
168
|
+
errors.username?.map(
|
|
169
|
+
(error) => html`<div>${error}</div>`,
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Validation Flow
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
User types
|
|
180
|
+
│
|
|
181
|
+
▼
|
|
182
|
+
Update model
|
|
183
|
+
│
|
|
184
|
+
▼
|
|
185
|
+
validateField("username")
|
|
186
|
+
│
|
|
187
|
+
▼
|
|
188
|
+
errors.username updated
|
|
189
|
+
│
|
|
190
|
+
▼
|
|
191
|
+
UI automatically re-renders
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
For form submission:
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
Submit
|
|
198
|
+
│
|
|
199
|
+
▼
|
|
200
|
+
isValid()
|
|
201
|
+
│
|
|
202
|
+
├── false → Display errors
|
|
203
|
+
│
|
|
204
|
+
└── true → Submit form
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Why use this helper?
|
|
210
|
+
|
|
211
|
+
- Minimal API
|
|
212
|
+
- Built on top of Zod
|
|
213
|
+
- No framework lock-in
|
|
214
|
+
- Supports both live validation and submit validation
|
|
215
|
+
- Keeps validation logic separate from UI components
|
|
216
|
+
- Works well with reactive state libraries
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare function createValidator<T extends Record<string, any>>(state: T, schema: z.ZodType<T>): {
|
|
3
|
+
errors: Partial<Record<keyof T, string[]>> extends infer T_1 ? T_1 extends Partial<Record<keyof T, string[]>> ? T_1 extends import("@arrow-js/core").Computed<infer TValue> ? TValue : T_1 extends import("@arrow-js/core").ReactiveTarget ? T_1 | import("@arrow-js/core").Reactive<T_1> : T_1 : never : never;
|
|
4
|
+
isValid: () => boolean;
|
|
5
|
+
validateField: (field: keyof T) => boolean;
|
|
6
|
+
validateAll: () => boolean;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3D,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;2BAkCU,MAAM,CAAC;;EA+DtC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { reactive } from '@arrow-js/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export function createValidator(state, schema) {
|
|
4
|
+
// 1. House the flags inside the reactive object shell
|
|
5
|
+
const validatorState = reactive({
|
|
6
|
+
errors: {},
|
|
7
|
+
isValid: false,
|
|
8
|
+
hasErrors: false,
|
|
9
|
+
});
|
|
10
|
+
const mapErrors = (issues) => {
|
|
11
|
+
const fieldErrors = {};
|
|
12
|
+
for (const issue of issues) {
|
|
13
|
+
const field = issue.path?.[0];
|
|
14
|
+
if (!field)
|
|
15
|
+
continue;
|
|
16
|
+
const message = issue.message;
|
|
17
|
+
fieldErrors[field] ??= new Set();
|
|
18
|
+
fieldErrors[field].add(message);
|
|
19
|
+
}
|
|
20
|
+
return fieldErrors;
|
|
21
|
+
};
|
|
22
|
+
// 2. Clear Type Checking Error: Object.keys(state) avoids ReactiveValue proxy walls
|
|
23
|
+
const syncValidationFlag = () => {
|
|
24
|
+
const hasErrors = Object.keys(state).some((key) => {
|
|
25
|
+
const fieldErrors = validatorState.errors[key];
|
|
26
|
+
return Array.isArray(fieldErrors) && fieldErrors.length > 0;
|
|
27
|
+
});
|
|
28
|
+
validatorState.hasErrors = hasErrors;
|
|
29
|
+
validatorState.isValid = !hasErrors;
|
|
30
|
+
};
|
|
31
|
+
const validateField = (field) => {
|
|
32
|
+
const result = schema.safeParse(state);
|
|
33
|
+
// Case 1: Entire form is clean and valid
|
|
34
|
+
if (result.success) {
|
|
35
|
+
validatorState.errors[field] = [];
|
|
36
|
+
syncValidationFlag();
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const mapped = mapErrors(result.error.issues);
|
|
40
|
+
// Case 2: This specific field has errors
|
|
41
|
+
validatorState.errors[field] = mapped[field]
|
|
42
|
+
? [...mapped[field]]
|
|
43
|
+
: [];
|
|
44
|
+
syncValidationFlag();
|
|
45
|
+
return !(validatorState.errors[field] &&
|
|
46
|
+
validatorState.errors[field].length > 0);
|
|
47
|
+
};
|
|
48
|
+
const validateAll = () => {
|
|
49
|
+
const result = schema.safeParse(state);
|
|
50
|
+
if (result.success) {
|
|
51
|
+
Object.keys(validatorState.errors).forEach((k) => {
|
|
52
|
+
validatorState.errors[k] = [];
|
|
53
|
+
});
|
|
54
|
+
syncValidationFlag();
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
const mapped = mapErrors(result.error.issues);
|
|
58
|
+
// Mirror the exact error state to the reactive errors object
|
|
59
|
+
// If a field isn't in mapped, it means it's valid -> clear it.
|
|
60
|
+
Object.keys(state).forEach((key) => {
|
|
61
|
+
const field = key;
|
|
62
|
+
validatorState.errors[field] = mapped[field]
|
|
63
|
+
? [...mapped[field]]
|
|
64
|
+
: [];
|
|
65
|
+
});
|
|
66
|
+
syncValidationFlag();
|
|
67
|
+
return false;
|
|
68
|
+
};
|
|
69
|
+
// 3. Return the single reactive proxy configuration block
|
|
70
|
+
return {
|
|
71
|
+
errors: validatorState.errors,
|
|
72
|
+
isValid: () => validatorState.isValid,
|
|
73
|
+
validateField,
|
|
74
|
+
validateAll,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,eAAe,CAC7B,KAAQ,EACR,MAAoB;IAEpB,sDAAsD;IACtD,MAAM,cAAc,GAAG,QAAQ,CAAC;QAC9B,MAAM,EAAE,EAAwC;QAChD,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;KACjB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,CAAC,MAAW,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K,CAAC;IACf,CAAC,CAAC;IAEF,0DAA0D;IAC1D,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,MAAM;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO;QACrC,aAAa;QACb,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/tests/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { reactive } from '@arrow-js/core';
|
|
4
|
+
import { createValidator } from '../index.js';
|
|
5
|
+
const schema = z.object({
|
|
6
|
+
username: z
|
|
7
|
+
.string()
|
|
8
|
+
.trim()
|
|
9
|
+
.min(1, 'Username is required.')
|
|
10
|
+
.min(5, 'Username must be at least 5 characters long.')
|
|
11
|
+
.max(20, 'Username must be at most 20 characters long.')
|
|
12
|
+
.regex(/^(?!.*[_]{2})[a-zA-Z0-9_]+$/, 'Username can only contain letters, numbers, and at least 1 underscore.'),
|
|
13
|
+
password: z
|
|
14
|
+
.string()
|
|
15
|
+
.trim()
|
|
16
|
+
.min(1, 'Password is required.')
|
|
17
|
+
.min(5, 'Password must be at least 5 characters long.')
|
|
18
|
+
.max(50, 'Password must be at most 50 characters long.'),
|
|
19
|
+
});
|
|
20
|
+
const input = reactive({
|
|
21
|
+
username: '',
|
|
22
|
+
password: '',
|
|
23
|
+
});
|
|
24
|
+
const { errors, validateField } = createValidator(input, schema);
|
|
25
|
+
test('Username empty string validation.', () => {
|
|
26
|
+
validateField('username');
|
|
27
|
+
console.log(errors);
|
|
28
|
+
expect(errors.username?.includes('Username is required.'));
|
|
29
|
+
});
|
|
30
|
+
test('Username minimun length validation.', () => {
|
|
31
|
+
validateField('username');
|
|
32
|
+
expect(errors.username?.includes('Username must be at least 5 characters long.'));
|
|
33
|
+
});
|
|
34
|
+
test('Username valid pattern validation.', () => {
|
|
35
|
+
validateField('username');
|
|
36
|
+
expect(errors.username?.includes('Username can only contain letters, numbers, and at least 1 underscore.'));
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/tests/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,GAAG,CAAC,CAAC,EAAE,8CAA8C,CAAC;SACtD,GAAG,CAAC,EAAE,EAAE,8CAA8C,CAAC;SACvD,KAAK,CACJ,6BAA6B,EAC7B,wEAAwE,CACzE;IAEH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,GAAG,CAAC,CAAC,EAAE,8CAA8C,CAAC;SACtD,GAAG,CAAC,EAAE,EAAE,8CAA8C,CAAC;CAC3D,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,QAAQ,CAAC;IACrB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjE,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC7C,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEpB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qCAAqC,EAAE,GAAG,EAAE;IAC/C,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1B,MAAM,CACJ,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,8CAA8C,CAAC,CAC1E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAC9C,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1B,MAAM,CACJ,MAAM,CAAC,QAAQ,EAAE,QAAQ,CACvB,wEAAwE,CACzE,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dev-dudu-0515/panasuri",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reactive Zod validation helper for ArrowJS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "vitest"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@arrow-js/core": "^1.0.6",
|
|
17
|
+
"zod": "^4.4.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^6.0.3",
|
|
21
|
+
"vitest": "^4.1.9"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|