yuppi 1.4.1 → 1.4.3
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 +30 -23
- package/dist/main.d.mts +8 -14
- package/dist/main.d.ts +8 -14
- package/dist/main.js +3 -5
- package/dist/main.mjs +3 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
2
2
|
[Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
3
3
|
[Boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
4
|
-
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
5
4
|
[Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
6
5
|
[Buffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
|
|
7
6
|
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
@@ -17,12 +16,19 @@
|
|
|
17
16
|
[PhoneNumber]: ./src/patterns/PhoneNumber.pattern.ts
|
|
18
17
|
[URI]: ./src/patterns/URI.pattern.ts
|
|
19
18
|
[Username]: ./src/patterns/Username.pattern.ts
|
|
19
|
+
|
|
20
|
+
<!---->
|
|
21
|
+
|
|
20
22
|
[YuppiOptionsDefault]: ./src/defaults/YuppiOptions.default.ts
|
|
23
|
+
|
|
24
|
+
<!---->
|
|
25
|
+
|
|
21
26
|
[AnyObject]: ./src/types/AnyObject.type.ts
|
|
22
27
|
[JSONSchema]: ./src/types/JSONSchema.type.ts
|
|
23
28
|
[Schema]: ./src/types/Schema.type.ts
|
|
24
29
|
[ValidationError]: ./src/types/ValidationError.type.ts
|
|
25
30
|
[YuppiOptions]: ./src/types/YuppiOptions.type.ts
|
|
31
|
+
[YupSchema]: ./src/types/YupSchema.type.ts
|
|
26
32
|
|
|
27
33
|
<div align="center">
|
|
28
34
|
<br/>
|
|
@@ -49,25 +55,24 @@
|
|
|
49
55
|
- [Types](#types)
|
|
50
56
|
- [Links](#links)
|
|
51
57
|
- [Discord](https://discord.gg/keift)
|
|
52
|
-
- [Telegram](https://t.me/
|
|
53
|
-
- [Twitter](https://x.com/
|
|
58
|
+
- [Telegram](https://t.me/keiftco)
|
|
59
|
+
- [Twitter](https://x.com/keiftco)
|
|
54
60
|
- [GitHub](https://github.com/keift)
|
|
55
61
|
- [License](#license)
|
|
56
62
|
|
|
57
63
|
## About
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
Portable and simple schemas for property validation.
|
|
60
66
|
|
|
61
67
|
## Features
|
|
62
68
|
|
|
63
|
-
- Easy and understandable
|
|
69
|
+
- Easy and understandable schemas
|
|
64
70
|
- Contains ready regex patterns
|
|
65
71
|
- Portable schemas as a JSON file
|
|
66
|
-
- Works with [Yup](https://npmjs.com/package/yup), stable and secure
|
|
67
72
|
- Schemas can be declared for TypeScript
|
|
68
|
-
-
|
|
73
|
+
- Schemas can be converted to [JSON Schema](https://json-schema.org). JSON Schema is OpenAPI compatible
|
|
69
74
|
- Error messages are ready to be understood but can be edited if desired
|
|
70
|
-
-
|
|
75
|
+
- Works with [Yup](https://npmjs.com/package/yup), stable and secure
|
|
71
76
|
|
|
72
77
|
## Installation
|
|
73
78
|
|
|
@@ -119,7 +124,8 @@ yuppi
|
|
|
119
124
|
├── type JSONSchema
|
|
120
125
|
├── type Schema
|
|
121
126
|
├── type ValidationError
|
|
122
|
-
|
|
127
|
+
├── type YuppiOptions
|
|
128
|
+
└── type YupSchema
|
|
123
129
|
```
|
|
124
130
|
|
|
125
131
|
### Import
|
|
@@ -136,9 +142,9 @@ import { Yuppi, Patterns } from 'yuppi';
|
|
|
136
142
|
|
|
137
143
|
Yuppi schema builder.
|
|
138
144
|
|
|
139
|
-
> | Parameter
|
|
140
|
-
> |
|
|
141
|
-
> | options
|
|
145
|
+
> | Parameter | Type | Default | Description |
|
|
146
|
+
> | ---------- | -------------- | --------------------- | ---------------------- |
|
|
147
|
+
> | `options?` | [YuppiOptions] | [YuppiOptionsDefault] | Constructor's options. |
|
|
142
148
|
>
|
|
143
149
|
> Example:
|
|
144
150
|
>
|
|
@@ -152,10 +158,10 @@ Yuppi schema builder.
|
|
|
152
158
|
|
|
153
159
|
Validate the properties with your Yuppi schema.
|
|
154
160
|
|
|
155
|
-
> | Parameter
|
|
156
|
-
> |
|
|
157
|
-
> | schema | [Schema] | | Yuppi schema. |
|
|
158
|
-
> | properties | [AnyObject] | | Properties to be validate. |
|
|
161
|
+
> | Parameter | Type | Default | Description |
|
|
162
|
+
> | ------------ | ----------- | ------- | -------------------------- |
|
|
163
|
+
> | `schema` | [Schema] | | Yuppi schema. |
|
|
164
|
+
> | `properties` | [AnyObject] | | Properties to be validate. |
|
|
159
165
|
>
|
|
160
166
|
> returns [Promise]<[AnyObject]>
|
|
161
167
|
>
|
|
@@ -240,8 +246,8 @@ Declare your Yuppi schema for TypeScript.
|
|
|
240
246
|
|
|
241
247
|
> | Parameter | Type | Default | Description |
|
|
242
248
|
> | --------- | -------- | ------- | ----------------- |
|
|
243
|
-
> | schema
|
|
244
|
-
> | name
|
|
249
|
+
> | `schema` | [Schema] | | Yuppi schema. |
|
|
250
|
+
> | `name` | [String] | | Declaration name. |
|
|
245
251
|
>
|
|
246
252
|
> returns [Promise]<[Void]>
|
|
247
253
|
>
|
|
@@ -271,9 +277,9 @@ Convert your Yuppi schema into Yup schema.
|
|
|
271
277
|
|
|
272
278
|
> | Parameter | Type | Default | Description |
|
|
273
279
|
> | --------- | -------- | ------- | ------------- |
|
|
274
|
-
> | schema
|
|
280
|
+
> | `schema` | [Schema] | | Yuppi schema. |
|
|
275
281
|
>
|
|
276
|
-
> returns [
|
|
282
|
+
> returns [YupSchema]
|
|
277
283
|
>
|
|
278
284
|
> Example:
|
|
279
285
|
>
|
|
@@ -289,7 +295,7 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
|
|
|
289
295
|
|
|
290
296
|
> | Parameter | Type | Default | Description |
|
|
291
297
|
> | --------- | -------- | ------- | ------------- |
|
|
292
|
-
> | schema
|
|
298
|
+
> | `schema` | [Schema] | | Yuppi schema. |
|
|
293
299
|
>
|
|
294
300
|
> returns [JSONSchema]
|
|
295
301
|
>
|
|
@@ -357,12 +363,13 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
|
|
|
357
363
|
| [Schema] |
|
|
358
364
|
| [ValidationError] |
|
|
359
365
|
| [YuppiOptions] |
|
|
366
|
+
| [YupSchema] |
|
|
360
367
|
|
|
361
368
|
## Links
|
|
362
369
|
|
|
363
370
|
- [Discord](https://discord.gg/keift)
|
|
364
|
-
- [Telegram](https://t.me/
|
|
365
|
-
- [Twitter](https://x.com/
|
|
371
|
+
- [Telegram](https://t.me/keiftco)
|
|
372
|
+
- [Twitter](https://x.com/keiftco)
|
|
366
373
|
- [GitHub](https://github.com/keift)
|
|
367
374
|
|
|
368
375
|
## License
|
package/dist/main.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { TObject, TAnySchema } from '@sinclair/typebox';
|
|
1
|
+
import { AnyObject as AnyObject$1, ValidateOptions, AnySchema, ValidationError as ValidationError$1 } from 'yup';
|
|
2
|
+
import { TAnySchema } from '@sinclair/typebox';
|
|
4
3
|
|
|
5
4
|
type AnyObject = AnyObject$1;
|
|
6
5
|
|
|
7
|
-
type JSONSchema =
|
|
6
|
+
type JSONSchema = TAnySchema;
|
|
8
7
|
|
|
9
8
|
type String = {
|
|
10
9
|
type: 'string';
|
|
@@ -108,20 +107,15 @@ type YuppiOptions = {
|
|
|
108
107
|
validate_options?: ValidateOptions;
|
|
109
108
|
};
|
|
110
109
|
|
|
110
|
+
type YupSchema = AnySchema;
|
|
111
|
+
|
|
111
112
|
declare class Yuppi {
|
|
112
113
|
private readonly options;
|
|
113
114
|
constructor(options?: YuppiOptions);
|
|
114
115
|
private cleanupTypesDir;
|
|
115
|
-
validate(schema: Schema, properties: AnyObject): Promise<
|
|
116
|
-
[x: string]: any;
|
|
117
|
-
[x: number]: any;
|
|
118
|
-
}>;
|
|
116
|
+
validate(schema: Schema, properties: AnyObject): Promise<AnyObject>;
|
|
119
117
|
declare(schema: Schema, name: string): Promise<void>;
|
|
120
|
-
convertToYup(schema: Schema):
|
|
121
|
-
[x: string]: any;
|
|
122
|
-
}, yup.AnyObject, {
|
|
123
|
-
[x: string]: any;
|
|
124
|
-
}, "">;
|
|
118
|
+
convertToYup(schema: Schema): YupSchema;
|
|
125
119
|
convertToJSONSchema(schema: Schema): JSONSchema;
|
|
126
120
|
}
|
|
127
121
|
|
|
@@ -149,4 +143,4 @@ declare namespace Patterns_export {
|
|
|
149
143
|
|
|
150
144
|
type ValidationError = ValidationError$1;
|
|
151
145
|
|
|
152
|
-
export { type AnyObject, type JSONSchema, Patterns_export as Patterns, type Schema, type ValidationError, Yuppi, type YuppiOptions };
|
|
146
|
+
export { type AnyObject, type JSONSchema, Patterns_export as Patterns, type Schema, type ValidationError, type YupSchema, Yuppi, type YuppiOptions };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { TObject, TAnySchema } from '@sinclair/typebox';
|
|
1
|
+
import { AnyObject as AnyObject$1, ValidateOptions, AnySchema, ValidationError as ValidationError$1 } from 'yup';
|
|
2
|
+
import { TAnySchema } from '@sinclair/typebox';
|
|
4
3
|
|
|
5
4
|
type AnyObject = AnyObject$1;
|
|
6
5
|
|
|
7
|
-
type JSONSchema =
|
|
6
|
+
type JSONSchema = TAnySchema;
|
|
8
7
|
|
|
9
8
|
type String = {
|
|
10
9
|
type: 'string';
|
|
@@ -108,20 +107,15 @@ type YuppiOptions = {
|
|
|
108
107
|
validate_options?: ValidateOptions;
|
|
109
108
|
};
|
|
110
109
|
|
|
110
|
+
type YupSchema = AnySchema;
|
|
111
|
+
|
|
111
112
|
declare class Yuppi {
|
|
112
113
|
private readonly options;
|
|
113
114
|
constructor(options?: YuppiOptions);
|
|
114
115
|
private cleanupTypesDir;
|
|
115
|
-
validate(schema: Schema, properties: AnyObject): Promise<
|
|
116
|
-
[x: string]: any;
|
|
117
|
-
[x: number]: any;
|
|
118
|
-
}>;
|
|
116
|
+
validate(schema: Schema, properties: AnyObject): Promise<AnyObject>;
|
|
119
117
|
declare(schema: Schema, name: string): Promise<void>;
|
|
120
|
-
convertToYup(schema: Schema):
|
|
121
|
-
[x: string]: any;
|
|
122
|
-
}, yup.AnyObject, {
|
|
123
|
-
[x: string]: any;
|
|
124
|
-
}, "">;
|
|
118
|
+
convertToYup(schema: Schema): YupSchema;
|
|
125
119
|
convertToJSONSchema(schema: Schema): JSONSchema;
|
|
126
120
|
}
|
|
127
121
|
|
|
@@ -149,4 +143,4 @@ declare namespace Patterns_export {
|
|
|
149
143
|
|
|
150
144
|
type ValidationError = ValidationError$1;
|
|
151
145
|
|
|
152
|
-
export { type AnyObject, type JSONSchema, Patterns_export as Patterns, type Schema, type ValidationError, Yuppi, type YuppiOptions };
|
|
146
|
+
export { type AnyObject, type JSONSchema, Patterns_export as Patterns, type Schema, type ValidationError, type YupSchema, Yuppi, type YuppiOptions };
|
package/dist/main.js
CHANGED
|
@@ -81,7 +81,7 @@ var convertToJSONSchema = (schema, options) => {
|
|
|
81
81
|
schema2 = import_typebox.Type.Array(build(key, config.items), { minItems: config.min, maxItems: config.max, default: config.default });
|
|
82
82
|
schema2 = base(schema2, key, config);
|
|
83
83
|
return schema2;
|
|
84
|
-
} else throw new Error(`
|
|
84
|
+
} else throw new Error(`Invalid schema type for ${key}`);
|
|
85
85
|
};
|
|
86
86
|
const build = (key, config) => {
|
|
87
87
|
if (!Array.isArray(config)) return buildSingle(key, config);
|
|
@@ -184,7 +184,7 @@ var convertToYup = (schema, options) => {
|
|
|
184
184
|
schema2 = schema2.of(build(key, config.items));
|
|
185
185
|
schema2 = base(schema2, key, config);
|
|
186
186
|
return schema2;
|
|
187
|
-
}
|
|
187
|
+
} else throw new Error(`Invalid schema type for ${key}`);
|
|
188
188
|
};
|
|
189
189
|
const build = (key, config) => {
|
|
190
190
|
if (!Array.isArray(config)) return buildSingle(key, config);
|
|
@@ -200,9 +200,7 @@ var convertToYup = (schema, options) => {
|
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
// src/utils/PascalCase.util.ts
|
|
203
|
-
var pascalCase = (text) =>
|
|
204
|
-
return text.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
205
|
-
};
|
|
203
|
+
var pascalCase = (text) => text.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
206
204
|
|
|
207
205
|
// src/defaults/YuppiOptions.default.ts
|
|
208
206
|
var YuppiOptionsDefault = {
|
package/dist/main.mjs
CHANGED
|
@@ -50,7 +50,7 @@ var convertToJSONSchema = (schema, options) => {
|
|
|
50
50
|
schema2 = Typebox.Array(build(key, config.items), { minItems: config.min, maxItems: config.max, default: config.default });
|
|
51
51
|
schema2 = base(schema2, key, config);
|
|
52
52
|
return schema2;
|
|
53
|
-
} else throw new Error(`
|
|
53
|
+
} else throw new Error(`Invalid schema type for ${key}`);
|
|
54
54
|
};
|
|
55
55
|
const build = (key, config) => {
|
|
56
56
|
if (!Array.isArray(config)) return buildSingle(key, config);
|
|
@@ -153,7 +153,7 @@ var convertToYup = (schema, options) => {
|
|
|
153
153
|
schema2 = schema2.of(build(key, config.items));
|
|
154
154
|
schema2 = base(schema2, key, config);
|
|
155
155
|
return schema2;
|
|
156
|
-
}
|
|
156
|
+
} else throw new Error(`Invalid schema type for ${key}`);
|
|
157
157
|
};
|
|
158
158
|
const build = (key, config) => {
|
|
159
159
|
if (!Array.isArray(config)) return buildSingle(key, config);
|
|
@@ -169,9 +169,7 @@ var convertToYup = (schema, options) => {
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
// src/utils/PascalCase.util.ts
|
|
172
|
-
var pascalCase = (text) =>
|
|
173
|
-
return text.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
174
|
-
};
|
|
172
|
+
var pascalCase = (text) => text.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
175
173
|
|
|
176
174
|
// src/defaults/YuppiOptions.default.ts
|
|
177
175
|
var YuppiOptionsDefault = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuppi",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.3",
|
|
4
|
+
"description": "Portable and simple schemas for property validation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/keift/yuppi",
|
|
7
7
|
"bugs": "https://github.com/keift/yuppi/issues",
|