@aeriajs/validation 0.0.136 → 0.0.138

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.
@@ -9,7 +9,7 @@ export type ValidateOptions = {
9
9
  };
10
10
  export declare const makeValidationError: <TValidationError extends ValidationError>(error: TValidationError) => TValidationError;
11
11
  export declare const validateProperty: <TWhat>(what: TWhat, property: Property | undefined, options?: ValidateOptions) => Result.Either<PropertyValidationError | ValidationError, unknown>;
12
- export declare const validateRefs: <TWhat>(what: TWhat, property: Property | Description | undefined, descriptions?: Record<string, Description>) => Promise<Result.Either<PropertyValidationError | ValidationError, unknown>>;
12
+ export declare const validateRefs: <TWhat>(what: TWhat, property: Property | Description | undefined, options?: ValidateOptions, descriptions?: Record<string, Description>) => Promise<Result.Either<PropertyValidationError | ValidationError, unknown>>;
13
13
  export declare const validateWholeness: (what: Record<string, unknown>, schema: Omit<JsonSchema, "$id">) => {
14
14
  code: ValidationErrorCode.MissingProperties;
15
15
  errors: {
package/dist/validate.js CHANGED
@@ -189,7 +189,7 @@ const validateProperty = (what, property, options = {}) => {
189
189
  return types_1.Result.result(what);
190
190
  };
191
191
  exports.validateProperty = validateProperty;
192
- const validateRefs = async (what, property, descriptions) => {
192
+ const validateRefs = async (what, property, options, descriptions) => {
193
193
  if (property) {
194
194
  if ('$ref' in property) {
195
195
  let description;
@@ -209,14 +209,14 @@ const validateRefs = async (what, property, descriptions) => {
209
209
  got: typeof what,
210
210
  }));
211
211
  }
212
- return (0, exports.validate)(what, description);
212
+ return (0, exports.validate)(what, description, options);
213
213
  }
214
214
  else if ('items' in property) {
215
215
  if (!Array.isArray(what)) {
216
216
  throw new Error;
217
217
  }
218
218
  for (const elem of what) {
219
- const { error } = await (0, exports.validateRefs)(elem, property.items, descriptions);
219
+ const { error } = await (0, exports.validateRefs)(elem, property.items, options, descriptions);
220
220
  if (error) {
221
221
  return types_1.Result.error(error);
222
222
  }
@@ -225,7 +225,7 @@ const validateRefs = async (what, property, descriptions) => {
225
225
  else if ('properties' in property) {
226
226
  const errors = {};
227
227
  for (const propName in what) {
228
- const { error } = await (0, exports.validateRefs)(what[propName], property.properties[propName], descriptions);
228
+ const { error } = await (0, exports.validateRefs)(what[propName], property.properties[propName], options, descriptions);
229
229
  if (error) {
230
230
  errors[propName] = error;
231
231
  }
package/dist/validate.mjs CHANGED
@@ -177,7 +177,7 @@ export const validateProperty = (what, property, options = {}) => {
177
177
  }
178
178
  return Result.result(what);
179
179
  };
180
- export const validateRefs = async (what, property, descriptions) => {
180
+ export const validateRefs = async (what, property, options, descriptions) => {
181
181
  if (property) {
182
182
  if ("$ref" in property) {
183
183
  let description;
@@ -196,13 +196,13 @@ export const validateRefs = async (what, property, descriptions) => {
196
196
  got: typeof what
197
197
  }));
198
198
  }
199
- return validate(what, description);
199
+ return validate(what, description, options);
200
200
  } else if ("items" in property) {
201
201
  if (!Array.isArray(what)) {
202
202
  throw new Error();
203
203
  }
204
204
  for (const elem of what) {
205
- const { error } = await validateRefs(elem, property.items, descriptions);
205
+ const { error } = await validateRefs(elem, property.items, options, descriptions);
206
206
  if (error) {
207
207
  return Result.error(error);
208
208
  }
@@ -210,7 +210,7 @@ export const validateRefs = async (what, property, descriptions) => {
210
210
  } else if ("properties" in property) {
211
211
  const errors = {};
212
212
  for (const propName in what) {
213
- const { error } = await validateRefs(what[propName], property.properties[propName], descriptions);
213
+ const { error } = await validateRefs(what[propName], property.properties[propName], options, descriptions);
214
214
  if (error) {
215
215
  errors[propName] = error;
216
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/validation",
3
- "version": "0.0.136",
3
+ "version": "0.0.138",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",