yuppi 1.2.6 → 1.2.8
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 +4 -2
- package/dist/main.d.mts +139 -17
- package/dist/main.d.ts +139 -17
- package/dist/main.js +47 -42
- package/dist/main.mjs +47 -42
- package/package.json +3 -3
- package/dist/Patterns.barrel-D-k3IHDq.d.mts +0 -20
- package/dist/Patterns.barrel-JdN3lL2Q.d.ts +0 -20
- package/dist/Yuppi.class.d.mts +0 -24
- package/dist/Yuppi.class.d.ts +0 -24
- package/dist/Yuppi.class.js +0 -244
- package/dist/Yuppi.class.mjs +0 -209
- package/dist/barrels/Patterns.barrel.d.mts +0 -7
- package/dist/barrels/Patterns.barrel.d.ts +0 -7
- package/dist/barrels/Patterns.barrel.js +0 -62
- package/dist/barrels/Patterns.barrel.mjs +0 -29
- package/dist/barrels/Types.barrel.d.mts +0 -8
- package/dist/barrels/Types.barrel.d.ts +0 -8
- package/dist/barrels/Types.barrel.js +0 -18
- package/dist/barrels/Types.barrel.mjs +0 -0
- package/dist/defaults/YuppiOptions.default.d.mts +0 -7
- package/dist/defaults/YuppiOptions.default.d.ts +0 -7
- package/dist/defaults/YuppiOptions.default.js +0 -73
- package/dist/defaults/YuppiOptions.default.mjs +0 -48
- package/dist/patterns/Any.pattern.d.mts +0 -3
- package/dist/patterns/Any.pattern.d.ts +0 -3
- package/dist/patterns/Any.pattern.js +0 -30
- package/dist/patterns/Any.pattern.mjs +0 -5
- package/dist/patterns/Domain.pattern.d.mts +0 -3
- package/dist/patterns/Domain.pattern.d.ts +0 -3
- package/dist/patterns/Domain.pattern.js +0 -30
- package/dist/patterns/Domain.pattern.mjs +0 -5
- package/dist/patterns/Email.pattern.d.mts +0 -3
- package/dist/patterns/Email.pattern.d.ts +0 -3
- package/dist/patterns/Email.pattern.js +0 -30
- package/dist/patterns/Email.pattern.mjs +0 -5
- package/dist/patterns/HTTP.pattern.d.mts +0 -3
- package/dist/patterns/HTTP.pattern.d.ts +0 -3
- package/dist/patterns/HTTP.pattern.js +0 -30
- package/dist/patterns/HTTP.pattern.mjs +0 -5
- package/dist/patterns/PhoneNumber.pattern.d.mts +0 -3
- package/dist/patterns/PhoneNumber.pattern.d.ts +0 -3
- package/dist/patterns/PhoneNumber.pattern.js +0 -30
- package/dist/patterns/PhoneNumber.pattern.mjs +0 -5
- package/dist/patterns/URI.pattern.d.mts +0 -3
- package/dist/patterns/URI.pattern.d.ts +0 -3
- package/dist/patterns/URI.pattern.js +0 -30
- package/dist/patterns/URI.pattern.mjs +0 -5
- package/dist/patterns/Username.pattern.d.mts +0 -3
- package/dist/patterns/Username.pattern.d.ts +0 -3
- package/dist/patterns/Username.pattern.js +0 -30
- package/dist/patterns/Username.pattern.mjs +0 -5
- package/dist/types/AnyObject.type.d.mts +0 -5
- package/dist/types/AnyObject.type.d.ts +0 -5
- package/dist/types/AnyObject.type.js +0 -18
- package/dist/types/AnyObject.type.mjs +0 -0
- package/dist/types/JSONSchema.type.d.mts +0 -5
- package/dist/types/JSONSchema.type.d.ts +0 -5
- package/dist/types/JSONSchema.type.js +0 -18
- package/dist/types/JSONSchema.type.mjs +0 -0
- package/dist/types/Schema.type.d.mts +0 -45
- package/dist/types/Schema.type.d.ts +0 -45
- package/dist/types/Schema.type.js +0 -18
- package/dist/types/Schema.type.mjs +0 -0
- package/dist/types/ValidateOptions.type.d.mts +0 -5
- package/dist/types/ValidateOptions.type.d.ts +0 -5
- package/dist/types/ValidateOptions.type.js +0 -18
- package/dist/types/ValidateOptions.type.mjs +0 -0
- package/dist/types/ValidationError.type.d.mts +0 -5
- package/dist/types/ValidationError.type.d.ts +0 -5
- package/dist/types/ValidationError.type.js +0 -18
- package/dist/types/ValidationError.type.mjs +0 -0
- package/dist/types/YuppiOptions.type.d.mts +0 -46
- package/dist/types/YuppiOptions.type.d.ts +0 -46
- package/dist/types/YuppiOptions.type.js +0 -18
- package/dist/types/YuppiOptions.type.mjs +0 -0
- package/dist/utils/ConvertToJSONSchema.util.d.mts +0 -7
- package/dist/utils/ConvertToJSONSchema.util.d.ts +0 -7
- package/dist/utils/ConvertToJSONSchema.util.js +0 -69
- package/dist/utils/ConvertToJSONSchema.util.mjs +0 -44
- package/dist/utils/ConvertToYup.util.d.mts +0 -12
- package/dist/utils/ConvertToYup.util.d.ts +0 -12
- package/dist/utils/ConvertToYup.util.js +0 -140
- package/dist/utils/ConvertToYup.util.mjs +0 -105
package/dist/Yuppi.class.mjs
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// src/Yuppi.class.ts
|
|
2
|
-
import _ from "lodash";
|
|
3
|
-
|
|
4
|
-
// src/utils/ConvertToYup.util.ts
|
|
5
|
-
import * as Yup from "yup";
|
|
6
|
-
|
|
7
|
-
// src/patterns/Any.pattern.ts
|
|
8
|
-
var Any = "[\\s\\S]*";
|
|
9
|
-
|
|
10
|
-
// src/utils/ConvertToYup.util.ts
|
|
11
|
-
var convertToYup = (schema, error_messages) => {
|
|
12
|
-
const base = (schema2, key, config) => {
|
|
13
|
-
schema2 = schema2.nullable();
|
|
14
|
-
if (config.required)
|
|
15
|
-
schema2 = schema2.test(
|
|
16
|
-
"required",
|
|
17
|
-
({ path }) => (error_messages?.base?.required ?? "").split("{path}").join(path),
|
|
18
|
-
(property) => {
|
|
19
|
-
if (property === void 0) return false;
|
|
20
|
-
if (typeof property === "string" && property.trim() === "") return false;
|
|
21
|
-
if (Array.isArray(property) && property.length === 0) return false;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
if (!config.nullable && config.default !== null) schema2 = schema2.nonNullable(({ path }) => (error_messages?.base?.nullable ?? "").split("{path}").join(path));
|
|
26
|
-
if (config.default !== void 0) schema2 = schema2.default(config.default);
|
|
27
|
-
if (config.pattern !== void 0 && schema2.matches !== void 0)
|
|
28
|
-
schema2 = schema2.matches(
|
|
29
|
-
new RegExp(config.pattern ?? Any),
|
|
30
|
-
({ path }) => (error_messages?.base?.pattern ?? "").split("{path}").join(path).split("{pattern}").join(new RegExp(config.pattern ?? Any).source)
|
|
31
|
-
);
|
|
32
|
-
return schema2;
|
|
33
|
-
};
|
|
34
|
-
const build = (key, config) => {
|
|
35
|
-
let schema2;
|
|
36
|
-
if (config.type === "string") {
|
|
37
|
-
schema2 = Yup.string().typeError(({ path }) => (error_messages?.string?.type ?? "").split("{path}").join(path));
|
|
38
|
-
schema2 = base(schema2, key, config);
|
|
39
|
-
schema2 = schema2.transform((property) => typeof property === "string" ? property.trim() : property);
|
|
40
|
-
if (config.enum !== void 0)
|
|
41
|
-
schema2 = schema2.oneOf(
|
|
42
|
-
config.enum.map((item) => item.trim()),
|
|
43
|
-
({ path }) => (error_messages?.string?.enum ?? "").split("{path}").join(path)
|
|
44
|
-
);
|
|
45
|
-
if (config.min !== void 0)
|
|
46
|
-
schema2 = schema2.min(
|
|
47
|
-
config.min,
|
|
48
|
-
({ path, min }) => (error_messages?.string?.min ?? "").split("{path}").join(path).split("{min}").join(min.toString()).split("{plural_suffix}").join(min > 1 ? "s" : "")
|
|
49
|
-
);
|
|
50
|
-
if (config.max !== void 0)
|
|
51
|
-
schema2 = schema2.max(
|
|
52
|
-
config.max,
|
|
53
|
-
({ path, max }) => (error_messages?.string?.max ?? "").split("{path}").join(path).split("{max}").join(max.toString()).split("{plural_suffix}").join(max > 1 ? "s" : "")
|
|
54
|
-
);
|
|
55
|
-
if (config.lowercase === true) schema2 = schema2.transform((property) => typeof property === "string" ? property.toLowerCase() : property);
|
|
56
|
-
if (config.uppercase === true) schema2 = schema2.transform((property) => typeof property === "string" ? property.toUpperCase() : property);
|
|
57
|
-
return schema2;
|
|
58
|
-
} else if (config.type === "number") {
|
|
59
|
-
schema2 = Yup.number().typeError(({ path }) => (error_messages?.number?.type ?? "").split("{path}").join(path));
|
|
60
|
-
schema2 = base(schema2, key, config);
|
|
61
|
-
if (config.enum !== void 0) schema2 = schema2.oneOf(config.enum, ({ path }) => (error_messages?.number?.enum ?? "").split("{path}").join(path));
|
|
62
|
-
if (config.min !== void 0) schema2 = schema2.min(config.min, ({ path, min }) => (error_messages?.number?.min ?? "").split("{path}").join(path).split("{min}").join(min.toString()));
|
|
63
|
-
if (config.max !== void 0) schema2 = schema2.max(config.max, ({ path, max }) => (error_messages?.number?.max ?? "").split("{path}").join(path).split("{max}").join(max.toString()));
|
|
64
|
-
if (config.integer === true) schema2 = schema2.integer(({ path }) => (error_messages?.number?.integer ?? "").split("{path}").join(path));
|
|
65
|
-
if (config.positive === true) schema2 = schema2.positive(({ path }) => (error_messages?.number?.positive ?? "").split("{path}").join(path));
|
|
66
|
-
if (config.negative === true) schema2 = schema2.negative(({ path }) => (error_messages?.number?.negative ?? "").split("{path}").join(path));
|
|
67
|
-
return schema2;
|
|
68
|
-
} else if (config.type === "boolean") {
|
|
69
|
-
schema2 = Yup.boolean().typeError(({ path }) => (error_messages?.boolean?.type ?? "").split("{path}").join(path));
|
|
70
|
-
schema2 = base(schema2, key, config);
|
|
71
|
-
return schema2;
|
|
72
|
-
} else if (config.type === "date") {
|
|
73
|
-
schema2 = Yup.date().typeError(({ path }) => (error_messages?.date?.type ?? "").split("{path}").join(path));
|
|
74
|
-
schema2 = base(schema2, key, config);
|
|
75
|
-
if (config.min !== void 0) schema2 = schema2.min(config.min, ({ path, min }) => (error_messages?.date?.min ?? "").split("{path}").join(path).split("{min}").join(new Date(min).toISOString()));
|
|
76
|
-
if (config.max !== void 0) schema2 = schema2.max(config.max, ({ path, max }) => (error_messages?.date?.max ?? "").split("{path}").join(path).split("{max}").join(new Date(max).toISOString()));
|
|
77
|
-
return schema2;
|
|
78
|
-
} else if (config.type === "object") {
|
|
79
|
-
schema2 = Yup.object().typeError(({ path }) => (error_messages?.object?.type ?? "").split("{path}").join(path));
|
|
80
|
-
schema2 = base(schema2, key, config);
|
|
81
|
-
const nested_properties = {};
|
|
82
|
-
for (const [nested_key, nested_config] of Object.entries(config.properties)) nested_properties[nested_key] = build(nested_key, nested_config);
|
|
83
|
-
schema2 = schema2.shape(nested_properties);
|
|
84
|
-
return schema2;
|
|
85
|
-
} else if (config.type === "array") {
|
|
86
|
-
schema2 = Yup.array().typeError(({ path }) => (error_messages?.array?.type ?? "").split("{path}").join(path));
|
|
87
|
-
schema2 = base(schema2, key, config);
|
|
88
|
-
if (config.min !== void 0)
|
|
89
|
-
schema2 = schema2.min(
|
|
90
|
-
config.min,
|
|
91
|
-
({ path, min }) => (error_messages?.array?.min ?? "").split("{path}").join(path).split("{min}").join(min.toString()).split("{plural_suffix}").join(min > 1 ? "s" : "")
|
|
92
|
-
);
|
|
93
|
-
if (config.max !== void 0)
|
|
94
|
-
schema2 = schema2.max(
|
|
95
|
-
config.max,
|
|
96
|
-
({ path, max }) => (error_messages?.array?.max ?? "").split("{path}").join(path).split("{max}").join(max.toString()).split("{plural_suffix}").join(max > 1 ? "s" : "")
|
|
97
|
-
);
|
|
98
|
-
schema2 = schema2.of(build(key, config.items));
|
|
99
|
-
return schema2;
|
|
100
|
-
} else throw new Error(`Unsupported schema type for ${key}`);
|
|
101
|
-
};
|
|
102
|
-
const properties = {};
|
|
103
|
-
for (const [key, config] of Object.entries(schema)) properties[key] = build(key, config);
|
|
104
|
-
return Yup.object().shape(properties);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// src/utils/ConvertToJSONSchema.util.ts
|
|
108
|
-
import { Type } from "@sinclair/typebox";
|
|
109
|
-
var convertToJSONSchema = (schema) => {
|
|
110
|
-
const build = (key, config) => {
|
|
111
|
-
if (config.type === "string") {
|
|
112
|
-
let schema2 = Type.String({ enum: config.enum, minLength: config.min, maxLength: config.max, pattern: new RegExp(config.pattern ?? Any).source, default: config.default });
|
|
113
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
114
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
115
|
-
} else if (config.type === "number") {
|
|
116
|
-
let schema2 = config.integer === true ? Type.Integer({ enum: config.enum, minimum: config.min, maximum: config.max, default: config.default }) : Type.Number({ enum: config.enum, minimum: config.min, maximum: config.max, default: config.default });
|
|
117
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
118
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
119
|
-
} else if (config.type === "boolean") {
|
|
120
|
-
let schema2 = Type.Boolean({ default: config.default });
|
|
121
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
122
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
123
|
-
} else if (config.type === "date") {
|
|
124
|
-
let schema2 = Type.String({ format: "date-time", minimum: config.min, maximum: config.max, pattern: new RegExp(config.pattern ?? Any).source, default: config.default });
|
|
125
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
126
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
127
|
-
} else if (config.type === "object") {
|
|
128
|
-
const nested_properties = {};
|
|
129
|
-
for (const [nested_key, nested_config] of Object.entries(config.properties)) nested_properties[nested_key] = build(nested_key, nested_config);
|
|
130
|
-
let schema2 = Type.Object(nested_properties);
|
|
131
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
132
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
133
|
-
} else if (config.type === "array") {
|
|
134
|
-
let schema2 = Type.Array(build(key, config.items), { minItems: config.min, maxItems: config.max, default: config.default });
|
|
135
|
-
if (config.nullable) schema2 = Type.Union([schema2, Type.Null()]);
|
|
136
|
-
return config.required ? schema2 : Type.Optional(schema2);
|
|
137
|
-
} else throw new Error(`Unsupported schema type for ${key}`);
|
|
138
|
-
};
|
|
139
|
-
const properties = {};
|
|
140
|
-
for (const [key, config] of Object.entries(schema)) properties[key] = build(key, config);
|
|
141
|
-
return Type.Object(properties);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// src/defaults/YuppiOptions.default.ts
|
|
145
|
-
var YuppiOptionsDefault = {
|
|
146
|
-
error_messages: {
|
|
147
|
-
base: {
|
|
148
|
-
pattern: "Field {path} must match the required pattern {pattern}",
|
|
149
|
-
nullable: "Field {path} cannot be null",
|
|
150
|
-
required: "Field {path} is required"
|
|
151
|
-
},
|
|
152
|
-
string: {
|
|
153
|
-
type: "Field {path} must be a string",
|
|
154
|
-
enum: "Field {path} must be one of the allowed values",
|
|
155
|
-
min: "Field {path} must be at least {min} character{plural_suffix}",
|
|
156
|
-
max: "Field {path} must be at most {max} character{plural_suffix}"
|
|
157
|
-
},
|
|
158
|
-
number: {
|
|
159
|
-
type: "Field {path} must be a number",
|
|
160
|
-
enum: "Field {path} must be one of the allowed values",
|
|
161
|
-
min: "Field {path} must be greater than or equal to {min}",
|
|
162
|
-
max: "Field {path} must be less than or equal to {max}",
|
|
163
|
-
integer: "Field {path} must be an integer",
|
|
164
|
-
positive: "Field {path} must be a positive",
|
|
165
|
-
negative: "Field {path} must be a negative"
|
|
166
|
-
},
|
|
167
|
-
boolean: {
|
|
168
|
-
type: "Field {path} must be a boolean"
|
|
169
|
-
},
|
|
170
|
-
date: {
|
|
171
|
-
type: "Field {path} must be a date",
|
|
172
|
-
min: "Field {path} must be after {min}",
|
|
173
|
-
max: "Field {path} must be before {max}"
|
|
174
|
-
},
|
|
175
|
-
object: {
|
|
176
|
-
type: "Field {path} must be an object"
|
|
177
|
-
},
|
|
178
|
-
array: {
|
|
179
|
-
type: "Field {path} must be an array",
|
|
180
|
-
min: "Field {path} must be at least {min} item${plural_suffix}",
|
|
181
|
-
max: "Field {path} must be at most {max} item${plural_suffix}"
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
validate_options: {
|
|
185
|
-
abortEarly: false,
|
|
186
|
-
stripUnknown: true
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// src/Yuppi.class.ts
|
|
191
|
-
var Yuppi = class {
|
|
192
|
-
constructor(options = YuppiOptionsDefault) {
|
|
193
|
-
this.options = _.merge({}, YuppiOptionsDefault, options);
|
|
194
|
-
}
|
|
195
|
-
validate(schema, properties) {
|
|
196
|
-
const yup_schema = convertToYup(schema, this.options.error_messages);
|
|
197
|
-
const validation = yup_schema.validateSync(properties, this.options.validate_options);
|
|
198
|
-
return validation;
|
|
199
|
-
}
|
|
200
|
-
convertToYup(schema) {
|
|
201
|
-
return convertToYup(schema, this.options.error_messages);
|
|
202
|
-
}
|
|
203
|
-
convertToJSONSchema(schema) {
|
|
204
|
-
return convertToJSONSchema(schema);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
export {
|
|
208
|
-
Yuppi
|
|
209
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { Any } from '../patterns/Any.pattern.mjs';
|
|
2
|
-
export { Domain } from '../patterns/Domain.pattern.mjs';
|
|
3
|
-
export { Email } from '../patterns/Email.pattern.mjs';
|
|
4
|
-
export { HTTP } from '../patterns/HTTP.pattern.mjs';
|
|
5
|
-
export { PhoneNumber } from '../patterns/PhoneNumber.pattern.mjs';
|
|
6
|
-
export { URI } from '../patterns/URI.pattern.mjs';
|
|
7
|
-
export { Username } from '../patterns/Username.pattern.mjs';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { Any } from '../patterns/Any.pattern.js';
|
|
2
|
-
export { Domain } from '../patterns/Domain.pattern.js';
|
|
3
|
-
export { Email } from '../patterns/Email.pattern.js';
|
|
4
|
-
export { HTTP } from '../patterns/HTTP.pattern.js';
|
|
5
|
-
export { PhoneNumber } from '../patterns/PhoneNumber.pattern.js';
|
|
6
|
-
export { URI } from '../patterns/URI.pattern.js';
|
|
7
|
-
export { Username } from '../patterns/Username.pattern.js';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/barrels/Patterns.barrel.ts
|
|
21
|
-
var Patterns_barrel_exports = {};
|
|
22
|
-
__export(Patterns_barrel_exports, {
|
|
23
|
-
Any: () => Any,
|
|
24
|
-
Domain: () => Domain,
|
|
25
|
-
Email: () => Email,
|
|
26
|
-
HTTP: () => HTTP,
|
|
27
|
-
PhoneNumber: () => PhoneNumber,
|
|
28
|
-
URI: () => URI,
|
|
29
|
-
Username: () => Username
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(Patterns_barrel_exports);
|
|
32
|
-
|
|
33
|
-
// src/patterns/Any.pattern.ts
|
|
34
|
-
var Any = "[\\s\\S]*";
|
|
35
|
-
|
|
36
|
-
// src/patterns/Domain.pattern.ts
|
|
37
|
-
var Domain = "^([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
38
|
-
|
|
39
|
-
// src/patterns/Email.pattern.ts
|
|
40
|
-
var Email = "^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
41
|
-
|
|
42
|
-
// src/patterns/HTTP.pattern.ts
|
|
43
|
-
var HTTP = "^(https?:\\/\\/)([a-zA-Z0-9._%+-]+(:[a-zA-Z0-9._%+-]+)?@)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(:\\d+)?(\\/[a-zA-Z0-9._-~%!$&'()*+,;=:@/]*)?(\\?[a-zA-Z0-9._~%!$&'()*+,;=:@/?-]*)?$";
|
|
44
|
-
|
|
45
|
-
// src/patterns/PhoneNumber.pattern.ts
|
|
46
|
-
var PhoneNumber = "^\\d{4}-\\d{7,12}$";
|
|
47
|
-
|
|
48
|
-
// src/patterns/URI.pattern.ts
|
|
49
|
-
var URI = "^([a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\/)([a-zA-Z0-9._%+-]+(:[a-zA-Z0-9._%+-]+)?@)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(:\\d+)?(\\/[a-zA-Z0-9._-~%!$&'()*+,;=:@/]*)?(\\?[a-zA-Z0-9._~%!$&'()*+,;=:@/?-]*)?$";
|
|
50
|
-
|
|
51
|
-
// src/patterns/Username.pattern.ts
|
|
52
|
-
var Username = "^(?=.*[a-zA-Z])[a-zA-Z0-9][a-zA-Z0-9_]*$";
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
Any,
|
|
56
|
-
Domain,
|
|
57
|
-
Email,
|
|
58
|
-
HTTP,
|
|
59
|
-
PhoneNumber,
|
|
60
|
-
URI,
|
|
61
|
-
Username
|
|
62
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// src/patterns/Any.pattern.ts
|
|
2
|
-
var Any = "[\\s\\S]*";
|
|
3
|
-
|
|
4
|
-
// src/patterns/Domain.pattern.ts
|
|
5
|
-
var Domain = "^([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
6
|
-
|
|
7
|
-
// src/patterns/Email.pattern.ts
|
|
8
|
-
var Email = "^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
9
|
-
|
|
10
|
-
// src/patterns/HTTP.pattern.ts
|
|
11
|
-
var HTTP = "^(https?:\\/\\/)([a-zA-Z0-9._%+-]+(:[a-zA-Z0-9._%+-]+)?@)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(:\\d+)?(\\/[a-zA-Z0-9._-~%!$&'()*+,;=:@/]*)?(\\?[a-zA-Z0-9._~%!$&'()*+,;=:@/?-]*)?$";
|
|
12
|
-
|
|
13
|
-
// src/patterns/PhoneNumber.pattern.ts
|
|
14
|
-
var PhoneNumber = "^\\d{4}-\\d{7,12}$";
|
|
15
|
-
|
|
16
|
-
// src/patterns/URI.pattern.ts
|
|
17
|
-
var URI = "^([a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\/)([a-zA-Z0-9._%+-]+(:[a-zA-Z0-9._%+-]+)?@)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(:\\d+)?(\\/[a-zA-Z0-9._-~%!$&'()*+,;=:@/]*)?(\\?[a-zA-Z0-9._~%!$&'()*+,;=:@/?-]*)?$";
|
|
18
|
-
|
|
19
|
-
// src/patterns/Username.pattern.ts
|
|
20
|
-
var Username = "^(?=.*[a-zA-Z])[a-zA-Z0-9][a-zA-Z0-9_]*$";
|
|
21
|
-
export {
|
|
22
|
-
Any,
|
|
23
|
-
Domain,
|
|
24
|
-
Email,
|
|
25
|
-
HTTP,
|
|
26
|
-
PhoneNumber,
|
|
27
|
-
URI,
|
|
28
|
-
Username
|
|
29
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { AnyObject } from '../types/AnyObject.type.mjs';
|
|
2
|
-
export { JSONSchema } from '../types/JSONSchema.type.mjs';
|
|
3
|
-
export { Schema } from '../types/Schema.type.mjs';
|
|
4
|
-
export { ValidateOptions } from '../types/ValidateOptions.type.mjs';
|
|
5
|
-
export { ValidationError } from '../types/ValidationError.type.mjs';
|
|
6
|
-
export { YuppiOptions } from '../types/YuppiOptions.type.mjs';
|
|
7
|
-
import 'yup';
|
|
8
|
-
import '@sinclair/typebox';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { AnyObject } from '../types/AnyObject.type.js';
|
|
2
|
-
export { JSONSchema } from '../types/JSONSchema.type.js';
|
|
3
|
-
export { Schema } from '../types/Schema.type.js';
|
|
4
|
-
export { ValidateOptions } from '../types/ValidateOptions.type.js';
|
|
5
|
-
export { ValidationError } from '../types/ValidationError.type.js';
|
|
6
|
-
export { YuppiOptions } from '../types/YuppiOptions.type.js';
|
|
7
|
-
import 'yup';
|
|
8
|
-
import '@sinclair/typebox';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/barrels/Types.barrel.ts
|
|
17
|
-
var Types_barrel_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(Types_barrel_exports);
|
|
File without changes
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/defaults/YuppiOptions.default.ts
|
|
21
|
-
var YuppiOptions_default_exports = {};
|
|
22
|
-
__export(YuppiOptions_default_exports, {
|
|
23
|
-
YuppiOptionsDefault: () => YuppiOptionsDefault
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(YuppiOptions_default_exports);
|
|
26
|
-
var YuppiOptionsDefault = {
|
|
27
|
-
error_messages: {
|
|
28
|
-
base: {
|
|
29
|
-
pattern: "Field {path} must match the required pattern {pattern}",
|
|
30
|
-
nullable: "Field {path} cannot be null",
|
|
31
|
-
required: "Field {path} is required"
|
|
32
|
-
},
|
|
33
|
-
string: {
|
|
34
|
-
type: "Field {path} must be a string",
|
|
35
|
-
enum: "Field {path} must be one of the allowed values",
|
|
36
|
-
min: "Field {path} must be at least {min} character{plural_suffix}",
|
|
37
|
-
max: "Field {path} must be at most {max} character{plural_suffix}"
|
|
38
|
-
},
|
|
39
|
-
number: {
|
|
40
|
-
type: "Field {path} must be a number",
|
|
41
|
-
enum: "Field {path} must be one of the allowed values",
|
|
42
|
-
min: "Field {path} must be greater than or equal to {min}",
|
|
43
|
-
max: "Field {path} must be less than or equal to {max}",
|
|
44
|
-
integer: "Field {path} must be an integer",
|
|
45
|
-
positive: "Field {path} must be a positive",
|
|
46
|
-
negative: "Field {path} must be a negative"
|
|
47
|
-
},
|
|
48
|
-
boolean: {
|
|
49
|
-
type: "Field {path} must be a boolean"
|
|
50
|
-
},
|
|
51
|
-
date: {
|
|
52
|
-
type: "Field {path} must be a date",
|
|
53
|
-
min: "Field {path} must be after {min}",
|
|
54
|
-
max: "Field {path} must be before {max}"
|
|
55
|
-
},
|
|
56
|
-
object: {
|
|
57
|
-
type: "Field {path} must be an object"
|
|
58
|
-
},
|
|
59
|
-
array: {
|
|
60
|
-
type: "Field {path} must be an array",
|
|
61
|
-
min: "Field {path} must be at least {min} item${plural_suffix}",
|
|
62
|
-
max: "Field {path} must be at most {max} item${plural_suffix}"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
validate_options: {
|
|
66
|
-
abortEarly: false,
|
|
67
|
-
stripUnknown: true
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
YuppiOptionsDefault
|
|
73
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// src/defaults/YuppiOptions.default.ts
|
|
2
|
-
var YuppiOptionsDefault = {
|
|
3
|
-
error_messages: {
|
|
4
|
-
base: {
|
|
5
|
-
pattern: "Field {path} must match the required pattern {pattern}",
|
|
6
|
-
nullable: "Field {path} cannot be null",
|
|
7
|
-
required: "Field {path} is required"
|
|
8
|
-
},
|
|
9
|
-
string: {
|
|
10
|
-
type: "Field {path} must be a string",
|
|
11
|
-
enum: "Field {path} must be one of the allowed values",
|
|
12
|
-
min: "Field {path} must be at least {min} character{plural_suffix}",
|
|
13
|
-
max: "Field {path} must be at most {max} character{plural_suffix}"
|
|
14
|
-
},
|
|
15
|
-
number: {
|
|
16
|
-
type: "Field {path} must be a number",
|
|
17
|
-
enum: "Field {path} must be one of the allowed values",
|
|
18
|
-
min: "Field {path} must be greater than or equal to {min}",
|
|
19
|
-
max: "Field {path} must be less than or equal to {max}",
|
|
20
|
-
integer: "Field {path} must be an integer",
|
|
21
|
-
positive: "Field {path} must be a positive",
|
|
22
|
-
negative: "Field {path} must be a negative"
|
|
23
|
-
},
|
|
24
|
-
boolean: {
|
|
25
|
-
type: "Field {path} must be a boolean"
|
|
26
|
-
},
|
|
27
|
-
date: {
|
|
28
|
-
type: "Field {path} must be a date",
|
|
29
|
-
min: "Field {path} must be after {min}",
|
|
30
|
-
max: "Field {path} must be before {max}"
|
|
31
|
-
},
|
|
32
|
-
object: {
|
|
33
|
-
type: "Field {path} must be an object"
|
|
34
|
-
},
|
|
35
|
-
array: {
|
|
36
|
-
type: "Field {path} must be an array",
|
|
37
|
-
min: "Field {path} must be at least {min} item${plural_suffix}",
|
|
38
|
-
max: "Field {path} must be at most {max} item${plural_suffix}"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
validate_options: {
|
|
42
|
-
abortEarly: false,
|
|
43
|
-
stripUnknown: true
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
YuppiOptionsDefault
|
|
48
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/patterns/Any.pattern.ts
|
|
21
|
-
var Any_pattern_exports = {};
|
|
22
|
-
__export(Any_pattern_exports, {
|
|
23
|
-
Any: () => Any
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Any_pattern_exports);
|
|
26
|
-
var Any = "[\\s\\S]*";
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
Any
|
|
30
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/patterns/Domain.pattern.ts
|
|
21
|
-
var Domain_pattern_exports = {};
|
|
22
|
-
__export(Domain_pattern_exports, {
|
|
23
|
-
Domain: () => Domain
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Domain_pattern_exports);
|
|
26
|
-
var Domain = "^([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
Domain
|
|
30
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/patterns/Email.pattern.ts
|
|
21
|
-
var Email_pattern_exports = {};
|
|
22
|
-
__export(Email_pattern_exports, {
|
|
23
|
-
Email: () => Email
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Email_pattern_exports);
|
|
26
|
-
var Email = "^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$";
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
Email
|
|
30
|
-
});
|