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 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 [Promise]<[AnyObject]>
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
- > Yupp.validate(schema, properties)
201
- > .then((properties: YuppiTypes.AnyObject) => {
202
- > console.log(properties);
203
- > /*
204
- > {
205
- > display_name: "Fırat",
206
- > username: "fir4tozden",
207
- > email: "fir4tozden@gmail.com"
208
- > }
209
- > */
210
- > })
211
- > .catch((error: YuppiTypes.ValidationError) => {
212
- > console.log(properties); // "Field email must match the required pattern ^[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$"
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/>
@@ -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): Promise<AnyObject>;
12
+ validate(schema: Schema, properties: AnyObject): AnyObject;
13
13
  convertToYup(schema: Schema): AnyObject;
14
14
  convertToJSONSchema(schema: Schema): JSONSchema;
15
15
  }
@@ -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): Promise<AnyObject>;
12
+ validate(schema: Schema, properties: AnyObject): AnyObject;
13
13
  convertToYup(schema: Schema): AnyObject;
14
14
  convertToJSONSchema(schema: Schema): JSONSchema;
15
15
  }
@@ -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
- async validate(schema, properties) {
216
+ validate(schema, properties) {
217
217
  const yup_schema = convertToYup(schema, this.options.error_messages);
218
- const validation = await yup_schema.validate(properties, this.options.validate_options);
218
+ const validation = yup_schema.validateSync(properties, this.options.validate_options);
219
219
  return validation;
220
220
  }
221
221
  convertToYup(schema) {
@@ -179,9 +179,9 @@ var Yuppi = class {
179
179
  constructor(options = YuppiOptionsDefault) {
180
180
  this.options = _.merge({}, YuppiOptionsDefault, options);
181
181
  }
182
- async validate(schema, properties) {
182
+ validate(schema, properties) {
183
183
  const yup_schema = convertToYup(schema, this.options.error_messages);
184
- const validation = await yup_schema.validate(properties, this.options.validate_options);
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
- async validate(schema, properties) {
219
+ validate(schema, properties) {
220
220
  const yup_schema = convertToYup(schema, this.options.error_messages);
221
- const validation = await yup_schema.validate(properties, this.options.validate_options);
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
- async validate(schema, properties) {
188
+ validate(schema, properties) {
189
189
  const yup_schema = convertToYup(schema, this.options.error_messages);
190
- const validation = await yup_schema.validate(properties, this.options.validate_options);
190
+ const validation = yup_schema.validateSync(properties, this.options.validate_options);
191
191
  return validation;
192
192
  }
193
193
  convertToYup(schema) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuppi",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
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",