yuppi 1.0.4 → 1.1.1
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 +16 -16
- package/dist/Yuppi.class.d.mts +1 -1
- package/dist/Yuppi.class.d.ts +1 -1
- package/dist/Yuppi.class.js +2 -2
- package/dist/Yuppi.class.mjs +2 -2
- package/dist/main.js +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
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
|
|
11
12
|
[Email]: ./src/patterns/Email.pattern.ts
|
|
12
13
|
[PhoneNumber]: ./src/patterns/PhoneNumber.pattern.ts
|
|
13
14
|
[URL]: ./src/patterns/URL.pattern.ts
|
|
14
15
|
[Username]: ./src/patterns/Username.pattern.ts
|
|
15
|
-
[YuppiOptionsDefault]: ./src/defaults/YuppiOptions.default.ts
|
|
16
16
|
[AnyObject]: https://github.com/jquense/yup/blob/master/src/util/objectTypes.ts#L7
|
|
17
17
|
[JSONSchema]: https://github.com/sinclairzx81/typebox/blob/master/src/type/object/object.ts#L78
|
|
18
18
|
[Schema]: ./src/types/Schema.type.ts
|
|
@@ -159,7 +159,7 @@ Validate the properties with your Yuppi schema.
|
|
|
159
159
|
> | schema | | [Schema]<br/>Yuppi schema. |
|
|
160
160
|
> | properties | | [AnyObject]<br/>Properties to be validate. |
|
|
161
161
|
>
|
|
162
|
-
> returns [
|
|
162
|
+
> returns [AnyObject]
|
|
163
163
|
>
|
|
164
164
|
> Example:
|
|
165
165
|
>
|
|
@@ -197,20 +197,20 @@ Validate the properties with your Yuppi schema.
|
|
|
197
197
|
> email: "fir4tozden@gmail.com"
|
|
198
198
|
> };
|
|
199
199
|
>
|
|
200
|
-
>
|
|
201
|
-
> .
|
|
202
|
-
>
|
|
203
|
-
>
|
|
204
|
-
>
|
|
205
|
-
>
|
|
206
|
-
>
|
|
207
|
-
>
|
|
208
|
-
>
|
|
209
|
-
>
|
|
210
|
-
>
|
|
211
|
-
>
|
|
212
|
-
>
|
|
213
|
-
>
|
|
200
|
+
> try {
|
|
201
|
+
> const validation = Yupp.validate(schema, properties);
|
|
202
|
+
>
|
|
203
|
+
> console.log(properties);
|
|
204
|
+
> /*
|
|
205
|
+
> {
|
|
206
|
+
> display_name: "Fırat",
|
|
207
|
+
> username: "fir4tozden",
|
|
208
|
+
> email: "fir4tozden@gmail.com"
|
|
209
|
+
> }
|
|
210
|
+
> */
|
|
211
|
+
> } catch((error: YuppiTypes.ValidationError)) {
|
|
212
|
+
> console.log(error.message); // "Field email must match the required pattern ^[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$"
|
|
213
|
+
> }
|
|
214
214
|
> ```
|
|
215
215
|
|
|
216
216
|
<br/>
|
package/dist/Yuppi.class.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import './types/ValidateOptions.type.mjs';
|
|
|
9
9
|
declare class Yuppi {
|
|
10
10
|
private readonly options;
|
|
11
11
|
constructor(options?: YuppiOptions);
|
|
12
|
-
validate(schema: Schema, properties: AnyObject):
|
|
12
|
+
validate(schema: Schema, properties: AnyObject): AnyObject;
|
|
13
13
|
convertToYup(schema: Schema): AnyObject;
|
|
14
14
|
convertToJSONSchema(schema: Schema): JSONSchema;
|
|
15
15
|
}
|
package/dist/Yuppi.class.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import './types/ValidateOptions.type.js';
|
|
|
9
9
|
declare class Yuppi {
|
|
10
10
|
private readonly options;
|
|
11
11
|
constructor(options?: YuppiOptions);
|
|
12
|
-
validate(schema: Schema, properties: AnyObject):
|
|
12
|
+
validate(schema: Schema, properties: AnyObject): AnyObject;
|
|
13
13
|
convertToYup(schema: Schema): AnyObject;
|
|
14
14
|
convertToJSONSchema(schema: Schema): JSONSchema;
|
|
15
15
|
}
|
package/dist/Yuppi.class.js
CHANGED
|
@@ -213,9 +213,9 @@ var Yuppi = class {
|
|
|
213
213
|
constructor(options = YuppiOptionsDefault) {
|
|
214
214
|
this.options = import_lodash.default.merge({}, YuppiOptionsDefault, options);
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
validate(schema, properties) {
|
|
217
217
|
const yup_schema = convertToYup(schema, this.options.error_messages);
|
|
218
|
-
const validation =
|
|
218
|
+
const validation = yup_schema.validateSync(properties, this.options.validate_options);
|
|
219
219
|
return validation;
|
|
220
220
|
}
|
|
221
221
|
convertToYup(schema) {
|
package/dist/Yuppi.class.mjs
CHANGED
|
@@ -179,9 +179,9 @@ var Yuppi = class {
|
|
|
179
179
|
constructor(options = YuppiOptionsDefault) {
|
|
180
180
|
this.options = _.merge({}, YuppiOptionsDefault, options);
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
validate(schema, properties) {
|
|
183
183
|
const yup_schema = convertToYup(schema, this.options.error_messages);
|
|
184
|
-
const validation =
|
|
184
|
+
const validation = yup_schema.validateSync(properties, this.options.validate_options);
|
|
185
185
|
return validation;
|
|
186
186
|
}
|
|
187
187
|
convertToYup(schema) {
|
package/dist/main.js
CHANGED
|
@@ -216,9 +216,9 @@ var Yuppi = class {
|
|
|
216
216
|
constructor(options = YuppiOptionsDefault) {
|
|
217
217
|
this.options = import_lodash.default.merge({}, YuppiOptionsDefault, options);
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
validate(schema, properties) {
|
|
220
220
|
const yup_schema = convertToYup(schema, this.options.error_messages);
|
|
221
|
-
const validation =
|
|
221
|
+
const validation = yup_schema.validateSync(properties, this.options.validate_options);
|
|
222
222
|
return validation;
|
|
223
223
|
}
|
|
224
224
|
convertToYup(schema) {
|
package/dist/main.mjs
CHANGED
|
@@ -185,9 +185,9 @@ var Yuppi = class {
|
|
|
185
185
|
constructor(options = YuppiOptionsDefault) {
|
|
186
186
|
this.options = _.merge({}, YuppiOptionsDefault, options);
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
validate(schema, properties) {
|
|
189
189
|
const yup_schema = convertToYup(schema, this.options.error_messages);
|
|
190
|
-
const validation =
|
|
190
|
+
const validation = yup_schema.validateSync(properties, this.options.validate_options);
|
|
191
191
|
return validation;
|
|
192
192
|
}
|
|
193
193
|
convertToYup(schema) {
|