yuppi 1.3.3 → 1.3.5
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 +3 -4
- package/dist/main.js +4 -2
- package/dist/main.mjs +4 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
[Function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
|
|
9
9
|
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
10
10
|
[Void]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined
|
|
11
|
-
[YuppiOptionsDefault]: ./src/defaults/YuppiOptions.default.ts
|
|
12
11
|
[Domain]: ./src/patterns/Domain.pattern.ts
|
|
13
12
|
[Email]: ./src/patterns/Email.pattern.ts
|
|
14
13
|
[HTTP]: ./src/patterns/HTTP.pattern.ts
|
|
15
14
|
[PhoneNumber]: ./src/patterns/PhoneNumber.pattern.ts
|
|
16
15
|
[URI]: ./src/patterns/URI.pattern.ts
|
|
17
16
|
[Username]: ./src/patterns/Username.pattern.ts
|
|
17
|
+
[YuppiOptionsDefault]: ./src/defaults/YuppiOptions.default.ts
|
|
18
18
|
[AnyObject]: https://github.com/jquense/yup/blob/master/src/util/objectTypes.ts#L7
|
|
19
19
|
[JSONSchema]: https://github.com/sinclairzx81/typebox/blob/master/src/type/object/object.ts#L78
|
|
20
20
|
[Schema]: ./src/types/Schema.type.ts
|
|
21
|
-
[ValidateOptions]: https://github.com/jquense/yup/blob/master/src/types.ts#
|
|
21
|
+
[ValidateOptions]: https://github.com/jquense/yup/blob/master/src/types.ts#L48
|
|
22
22
|
[ValidationError]: https://github.com/jquense/yup/blob/master/src/ValidationError.ts#L53
|
|
23
23
|
[YuppiOptions]: ./src/types/YuppiOptions.type.ts
|
|
24
24
|
|
|
@@ -62,6 +62,7 @@ Schemas that can be converted to Yup and JSON Schema.
|
|
|
62
62
|
- Contains ready regex patterns
|
|
63
63
|
- Portable schemas as a JSON file
|
|
64
64
|
- Works with Yup, stable and secure
|
|
65
|
+
- Schemas can be declared for TypeScript
|
|
65
66
|
- It is strict and therefore does not accept more than one type
|
|
66
67
|
- Error messages are ready to be understood but can be edited if desired
|
|
67
68
|
- Can be converted to Yup and [JSON Schema](https://json-schema.org). JSON Schema is OpenAPI compatible
|
|
@@ -162,7 +163,6 @@ Validate the properties with your Yuppi schema.
|
|
|
162
163
|
> const schema: Schema = {
|
|
163
164
|
> display_name: {
|
|
164
165
|
> type: 'string',
|
|
165
|
-
> min: 1,
|
|
166
166
|
> max: 32,
|
|
167
167
|
> nullable: false,
|
|
168
168
|
> required: true
|
|
@@ -278,7 +278,6 @@ Convert your Yuppi schema into [JSON Schema](https://json-schema.org).
|
|
|
278
278
|
> properties: {
|
|
279
279
|
> display_name: {
|
|
280
280
|
> type: "string",
|
|
281
|
-
> minLength: 1,
|
|
282
281
|
> maxLength: 32,
|
|
283
282
|
> },
|
|
284
283
|
> username: {
|
package/dist/main.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(main_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/Yuppi.class.ts
|
|
39
39
|
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
40
|
-
var import_lodash = __toESM(require("lodash"));
|
|
40
|
+
var import_lodash = __toESM(require("lodash.merge"));
|
|
41
41
|
var import_fs = __toESM(require("fs"));
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
|
|
@@ -56,6 +56,8 @@ var convertToJSONSchema = (schema) => {
|
|
|
56
56
|
schema2 = base(schema2, key, config);
|
|
57
57
|
return schema2;
|
|
58
58
|
} else if (config.type === "number") {
|
|
59
|
+
if (config.positive) config.min = 1;
|
|
60
|
+
if (config.negative) config.max = -1;
|
|
59
61
|
schema2 = config.integer === true ? import_typebox.Type.Integer({ enum: config.enum, minimum: config.min, maximum: config.max, positive: config.positive, negative: config.negative, default: config.default }) : import_typebox.Type.Number({ enum: config.enum, minimum: config.min, maximum: config.max, positive: config.positive, negative: config.negative, default: config.default });
|
|
60
62
|
schema2 = base(schema2, key, config);
|
|
61
63
|
return schema2;
|
|
@@ -234,7 +236,7 @@ var YuppiOptionsDefault = {
|
|
|
234
236
|
var Yuppi = class {
|
|
235
237
|
options;
|
|
236
238
|
constructor(options = YuppiOptionsDefault) {
|
|
237
|
-
this.options = import_lodash.default
|
|
239
|
+
this.options = (0, import_lodash.default)({}, YuppiOptionsDefault, options);
|
|
238
240
|
}
|
|
239
241
|
validate(schema, properties) {
|
|
240
242
|
const yup_schema = this.convertToYup(schema);
|
package/dist/main.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/Yuppi.class.ts
|
|
8
8
|
import { compile } from "json-schema-to-typescript";
|
|
9
|
-
import
|
|
9
|
+
import merge from "lodash.merge";
|
|
10
10
|
import fs from "fs";
|
|
11
11
|
import path from "path";
|
|
12
12
|
|
|
@@ -25,6 +25,8 @@ var convertToJSONSchema = (schema) => {
|
|
|
25
25
|
schema2 = base(schema2, key, config);
|
|
26
26
|
return schema2;
|
|
27
27
|
} else if (config.type === "number") {
|
|
28
|
+
if (config.positive) config.min = 1;
|
|
29
|
+
if (config.negative) config.max = -1;
|
|
28
30
|
schema2 = config.integer === true ? Type.Integer({ enum: config.enum, minimum: config.min, maximum: config.max, positive: config.positive, negative: config.negative, default: config.default }) : Type.Number({ enum: config.enum, minimum: config.min, maximum: config.max, positive: config.positive, negative: config.negative, default: config.default });
|
|
29
31
|
schema2 = base(schema2, key, config);
|
|
30
32
|
return schema2;
|
|
@@ -203,7 +205,7 @@ var YuppiOptionsDefault = {
|
|
|
203
205
|
var Yuppi = class {
|
|
204
206
|
options;
|
|
205
207
|
constructor(options = YuppiOptionsDefault) {
|
|
206
|
-
this.options =
|
|
208
|
+
this.options = merge({}, YuppiOptionsDefault, options);
|
|
207
209
|
}
|
|
208
210
|
validate(schema, properties) {
|
|
209
211
|
const yup_schema = this.convertToYup(schema);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuppi",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Schemas that can be converted to Yup and JSON Schema.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/keift/yuppi",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sinclair/typebox": "^0.34.41",
|
|
19
|
-
"@types/lodash": "^4.
|
|
20
|
-
"@types/node": "^24.6.
|
|
19
|
+
"@types/lodash.merge": "^4.6.9",
|
|
20
|
+
"@types/node": "^24.6.2",
|
|
21
21
|
"json-schema-to-typescript": "^15.0.4",
|
|
22
|
-
"lodash": "^4.
|
|
22
|
+
"lodash.merge": "^4.6.2",
|
|
23
23
|
"yup": "^1.7.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"neatlint": "^1.1.
|
|
26
|
+
"neatlint": "^1.1.18",
|
|
27
27
|
"prettier": "^3.6.2",
|
|
28
28
|
"tsup": "^8.5.0"
|
|
29
29
|
},
|