Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contember/schema-utils

Package Overview
Dependencies
Maintainers
5
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/schema-utils - npm Package Compare versions

Comparing version 0.6.3 to 0.6.6

dist/src/validation/ModelValidator.d.ts

2

dist/src/validation/SchemaValidator.d.ts
import { Schema } from '@contember/schema';
import { ValidationError } from './errors';
export declare class SchemaValidator {
validate(schema: Schema): [Schema, ValidationError[]];
static validate(schema: Schema): ValidationError[];
}
//# sourceMappingURL=SchemaValidator.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AclValidator_1 = require("./AclValidator");
const ModelValidator_1 = require("./ModelValidator");
const util_1 = require("util");
class SchemaValidator {
validate(schema) {
static validate(schema) {
const aclValidator = new AclValidator_1.AclValidator(schema.model);
const [acl, aclErrors] = aclValidator.validate(schema.acl);
return [{ ...schema, acl }, [...aclErrors]];
const modelValidator = new ModelValidator_1.ModelValidator(schema.model);
const [model, modelErrors] = modelValidator.validate();
const validSchema = { ...schema, acl, model };
const errors = [...aclErrors, ...modelErrors];
if (errors.length === 0 && !util_1.isDeepStrictEqual(validSchema, schema)) {
throw new Error('There is something wrong with a schema validator');
}
return errors;
}

@@ -10,0 +19,0 @@ }

{
"name": "@contember/schema-utils",
"version": "0.6.3",
"version": "0.6.6",
"license": "Apache-2.0",

@@ -9,3 +9,3 @@ "main": "dist/src/index.js",

"dependencies": {
"@contember/schema": "^0.6.3"
"@contember/schema": "^0.6.6"
},

@@ -16,3 +16,3 @@ "devDependencies": {

},
"gitHead": "ce4b6bfeea630fa2dd2d2d06f10cf813e7cd742c"
"gitHead": "6cd07fb5b509c443a1478a60b3d088abd73c8f3c"
}
import { Schema } from '@contember/schema'
import { ValidationError } from './errors'
import { AclValidator } from './AclValidator'
import { ModelValidator } from './ModelValidator'
import { isDeepStrictEqual } from 'util'
export class SchemaValidator {
public validate(schema: Schema): [Schema, ValidationError[]] {
public static validate(schema: Schema): ValidationError[] {
const aclValidator = new AclValidator(schema.model)
const [acl, aclErrors] = aclValidator.validate(schema.acl)
return [{ ...schema, acl }, [...aclErrors]]
const modelValidator = new ModelValidator(schema.model)
const [model, modelErrors] = modelValidator.validate()
const validSchema = { ...schema, acl, model }
const errors = [...aclErrors, ...modelErrors]
if (errors.length === 0 && !isDeepStrictEqual(validSchema, schema)) {
throw new Error('There is something wrong with a schema validator')
}
return errors
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc