yuppi 1.4.1 → 1.4.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 +15 -7
- package/dist/main.d.mts +6 -4
- package/dist/main.d.ts +6 -4
- package/dist/main.js +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,12 +17,19 @@
|
|
|
17
17
|
[PhoneNumber]: ./src/patterns/PhoneNumber.pattern.ts
|
|
18
18
|
[URI]: ./src/patterns/URI.pattern.ts
|
|
19
19
|
[Username]: ./src/patterns/Username.pattern.ts
|
|
20
|
+
|
|
21
|
+
<!---->
|
|
22
|
+
|
|
20
23
|
[YuppiOptionsDefault]: ./src/defaults/YuppiOptions.default.ts
|
|
24
|
+
|
|
25
|
+
<!---->
|
|
26
|
+
|
|
21
27
|
[AnyObject]: ./src/types/AnyObject.type.ts
|
|
22
28
|
[JSONSchema]: ./src/types/JSONSchema.type.ts
|
|
23
29
|
[Schema]: ./src/types/Schema.type.ts
|
|
24
30
|
[ValidationError]: ./src/types/ValidationError.type.ts
|
|
25
31
|
[YuppiOptions]: ./src/types/YuppiOptions.type.ts
|
|
32
|
+
[YupSchema]: ./src/types/YupSchema.type.ts
|
|
26
33
|
|
|
27
34
|
<div align="center">
|
|
28
35
|
<br/>
|
|
@@ -56,18 +63,17 @@
|
|
|
56
63
|
|
|
57
64
|
## About
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
Portable and simple schemas for property validation.
|
|
60
67
|
|
|
61
68
|
## Features
|
|
62
69
|
|
|
63
|
-
- Easy and understandable
|
|
70
|
+
- Easy and understandable schemas
|
|
64
71
|
- Contains ready regex patterns
|
|
65
72
|
- Portable schemas as a JSON file
|
|
66
|
-
- Works with [Yup](https://npmjs.com/package/yup), stable and secure
|
|
67
73
|
- Schemas can be declared for TypeScript
|
|
68
|
-
-
|
|
74
|
+
- Schemas can be converted to [JSON Schema](https://json-schema.org). JSON Schema is OpenAPI compatible
|
|
69
75
|
- Error messages are ready to be understood but can be edited if desired
|
|
70
|
-
-
|
|
76
|
+
- Works with [Yup](https://npmjs.com/package/yup), stable and secure
|
|
71
77
|
|
|
72
78
|
## Installation
|
|
73
79
|
|
|
@@ -119,7 +125,8 @@ yuppi
|
|
|
119
125
|
├── type JSONSchema
|
|
120
126
|
├── type Schema
|
|
121
127
|
├── type ValidationError
|
|
122
|
-
|
|
128
|
+
├── type YuppiOptions
|
|
129
|
+
└── type YupSchema
|
|
123
130
|
```
|
|
124
131
|
|
|
125
132
|
### Import
|
|
@@ -273,7 +280,7 @@ Convert your Yuppi schema into Yup schema.
|
|
|
273
280
|
> | --------- | -------- | ------- | ------------- |
|
|
274
281
|
> | schema | [Schema] | | Yuppi schema. |
|
|
275
282
|
>
|
|
276
|
-
> returns [
|
|
283
|
+
> returns [YupSchema]
|
|
277
284
|
>
|
|
278
285
|
> Example:
|
|
279
286
|
>
|
|
@@ -357,6 +364,7 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
|
|
|
357
364
|
| [Schema] |
|
|
358
365
|
| [ValidationError] |
|
|
359
366
|
| [YuppiOptions] |
|
|
367
|
+
| [YupSchema] |
|
|
360
368
|
|
|
361
369
|
## Links
|
|
362
370
|
|
package/dist/main.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
import { AnyObject as AnyObject$1, ValidateOptions, ValidationError as ValidationError$1 } from 'yup';
|
|
3
|
-
import {
|
|
2
|
+
import { AnyObject as AnyObject$1, ValidateOptions, ValidationError as ValidationError$1, AnySchema } from 'yup';
|
|
3
|
+
import { TAnySchema } from '@sinclair/typebox';
|
|
4
4
|
|
|
5
5
|
type AnyObject = AnyObject$1;
|
|
6
6
|
|
|
7
|
-
type JSONSchema =
|
|
7
|
+
type JSONSchema = TAnySchema;
|
|
8
8
|
|
|
9
9
|
type String = {
|
|
10
10
|
type: 'string';
|
|
@@ -149,4 +149,6 @@ declare namespace Patterns_export {
|
|
|
149
149
|
|
|
150
150
|
type ValidationError = ValidationError$1;
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
type YupSchema = AnySchema;
|
|
153
|
+
|
|
154
|
+
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,10 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
import { AnyObject as AnyObject$1, ValidateOptions, ValidationError as ValidationError$1 } from 'yup';
|
|
3
|
-
import {
|
|
2
|
+
import { AnyObject as AnyObject$1, ValidateOptions, ValidationError as ValidationError$1, AnySchema } from 'yup';
|
|
3
|
+
import { TAnySchema } from '@sinclair/typebox';
|
|
4
4
|
|
|
5
5
|
type AnyObject = AnyObject$1;
|
|
6
6
|
|
|
7
|
-
type JSONSchema =
|
|
7
|
+
type JSONSchema = TAnySchema;
|
|
8
8
|
|
|
9
9
|
type String = {
|
|
10
10
|
type: 'string';
|
|
@@ -149,4 +149,6 @@ declare namespace Patterns_export {
|
|
|
149
149
|
|
|
150
150
|
type ValidationError = ValidationError$1;
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
type YupSchema = AnySchema;
|
|
153
|
+
|
|
154
|
+
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);
|
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);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuppi",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.2",
|
|
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",
|