@hestia-earth/schema-validation 26.1.0 → 26.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-validation",
3
- "version": "26.1.0",
3
+ "version": "26.2.0",
4
4
  "description": "Hestia Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
package/validate.d.ts CHANGED
@@ -11,8 +11,9 @@ import { definitions } from '@hestia-earth/json-schema';
11
11
  export declare const validateContent: (ajv: Ajv.Ajv, schemas: definitions) => (content: HestiaJson<SchemaType>) => Promise<{
12
12
  success: any;
13
13
  errors: {
14
- parentSchema?: object;
15
- schema?: any;
14
+ schema?: {
15
+ required?: any;
16
+ };
16
17
  dataPath: string;
17
18
  schemaPath: string;
18
19
  params: Ajv.ErrorParameters;
@@ -32,8 +33,9 @@ export declare const initAjv: () => Ajv.Ajv;
32
33
  export declare const validator: (domain?: string, strictMode?: boolean) => (content: HestiaJson<SchemaType>) => Promise<{
33
34
  success: any;
34
35
  errors: {
35
- parentSchema?: object;
36
- schema?: any;
36
+ schema?: {
37
+ required?: any;
38
+ };
37
39
  dataPath: string;
38
40
  schemaPath: string;
39
41
  params: Ajv.ErrorParameters;
package/validate.js CHANGED
@@ -71,18 +71,15 @@ var validateSchemaType = function (schemas, content) {
71
71
  }
72
72
  return true;
73
73
  };
74
- var ignoreSchemaKeywords = ['if', validators_1.arraySameSize, validators_1.geojson, validators_1.uniqueArrayItem];
75
- var includeSchema = function (keyword, schema) {
76
- return [!ignoreSchemaKeywords.includes(keyword), typeof schema === 'object'].every(Boolean);
77
- };
78
- var includeParentSchema = function (keyword, schema, parentSchema) {
79
- return [includeSchema(keyword, schema), !(0, schema_1.isTypeNode)(parentSchema.title)].every(Boolean);
74
+ var schemaData = function (_a) {
75
+ var required = _a.required;
76
+ return (__assign({}, ((required === null || required === void 0 ? void 0 : required.length) ? { required: required } : {})));
80
77
  };
81
78
  // using `verbose: true` includes data which we don't need
82
79
  var cleanErrors = function (errors) {
83
80
  return errors.map(function (_a) {
84
81
  var keyword = _a.keyword, data = _a.data, schema = _a.schema, parentSchema = _a.parentSchema, error = __rest(_a, ["keyword", "data", "schema", "parentSchema"]);
85
- return (__assign(__assign(__assign({ keyword: keyword }, error), (!!schema && includeSchema(keyword, schema) ? { schema: schema } : {})), (!!parentSchema && includeParentSchema(keyword, schema, parentSchema) ? { parentSchema: parentSchema } : {})));
82
+ return (__assign(__assign({ keyword: keyword }, error), (schema ? { schema: schemaData(schema) } : {})));
86
83
  });
87
84
  };
88
85
  /**