@esmj/schema 0.3.1 → 0.3.2
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/README.md +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ When choosing a schema validation library, bundle size can be an important facto
|
|
|
33
33
|
|
|
34
34
|
| Library | Bundle Size (minified + gzipped) |
|
|
35
35
|
|------------------|---------------------------------|
|
|
36
|
-
| `@esmj/schema` | `~1 KB`
|
|
36
|
+
| `@esmj/schema` | `~1,1 KB` |
|
|
37
37
|
| Superstruct | ~3.2 KB |
|
|
38
38
|
| Yup | ~12.2 KB |
|
|
39
39
|
| Zod@3 | ~13 KB |
|
|
@@ -132,7 +132,7 @@ console.log(result);
|
|
|
132
132
|
|
|
133
133
|
#### `s.string(options?)`
|
|
134
134
|
|
|
135
|
-
Creates a string schema. You can optionally pass `
|
|
135
|
+
Creates a string schema. You can optionally pass `options` to customize error messages.
|
|
136
136
|
|
|
137
137
|
```typescript
|
|
138
138
|
const stringSchema = s.string({
|
|
@@ -142,7 +142,7 @@ const stringSchema = s.string({
|
|
|
142
142
|
|
|
143
143
|
#### `s.number(options?)`
|
|
144
144
|
|
|
145
|
-
Creates a number schema. You can optionally pass `
|
|
145
|
+
Creates a number schema. You can optionally pass `options` to customize error messages.
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
148
|
const numberSchema = s.number({
|
|
@@ -152,7 +152,7 @@ const numberSchema = s.number({
|
|
|
152
152
|
|
|
153
153
|
#### `s.boolean(options?)`
|
|
154
154
|
|
|
155
|
-
Creates a boolean schema. You can optionally pass `
|
|
155
|
+
Creates a boolean schema. You can optionally pass `options` to customize error messages.
|
|
156
156
|
|
|
157
157
|
```typescript
|
|
158
158
|
const booleanSchema = s.boolean({
|
|
@@ -162,7 +162,7 @@ const booleanSchema = s.boolean({
|
|
|
162
162
|
|
|
163
163
|
#### `s.date(options?)`
|
|
164
164
|
|
|
165
|
-
Creates a date schema. You can optionally pass `
|
|
165
|
+
Creates a date schema. You can optionally pass `options` to customize error messages.
|
|
166
166
|
|
|
167
167
|
```typescript
|
|
168
168
|
const dateSchema = s.date({
|
|
@@ -172,7 +172,7 @@ const dateSchema = s.date({
|
|
|
172
172
|
|
|
173
173
|
#### `s.object(definition, options?)`
|
|
174
174
|
|
|
175
|
-
Creates an object schema with the given definition. You can optionally pass `
|
|
175
|
+
Creates an object schema with the given definition. You can optionally pass `options` to customize error messages.
|
|
176
176
|
|
|
177
177
|
```typescript
|
|
178
178
|
const objectSchema = s.object(
|
|
@@ -188,7 +188,7 @@ const objectSchema = s.object(
|
|
|
188
188
|
|
|
189
189
|
#### `s.array(definition, options?)`
|
|
190
190
|
|
|
191
|
-
Creates an array schema with the given item definition. You can optionally pass `
|
|
191
|
+
Creates an array schema with the given item definition. You can optionally pass `options` to customize error messages.
|
|
192
192
|
|
|
193
193
|
```typescript
|
|
194
194
|
const arraySchema = s.array(s.string(), {
|
|
@@ -198,7 +198,7 @@ const arraySchema = s.array(s.string(), {
|
|
|
198
198
|
|
|
199
199
|
#### `s.enum(values, options?)`
|
|
200
200
|
|
|
201
|
-
Creates an enum schema that validates against a predefined set of string values. You can optionally pass `
|
|
201
|
+
Creates an enum schema that validates against a predefined set of string values. You can optionally pass `options` to customize error messages.
|
|
202
202
|
|
|
203
203
|
- **`values`**: An array of strings representing the allowed values for the enum. Each value must be a string.
|
|
204
204
|
|
|
@@ -210,7 +210,7 @@ const enumSchema = s.enum(['admin', 'user', 'guest'], {
|
|
|
210
210
|
|
|
211
211
|
#### `s.union(definitions, options?)`
|
|
212
212
|
|
|
213
|
-
Creates a schema that validates against multiple schemas (a union of schemas). The value must match at least one of the provided schemas. You can optionally pass `
|
|
213
|
+
Creates a schema that validates against multiple schemas (a union of schemas). The value must match at least one of the provided schemas. You can optionally pass `options` to customize error messages.
|
|
214
214
|
|
|
215
215
|
- **`definitions`**: An array of schemas to validate against.
|
|
216
216
|
|