You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
663 B
JavaScript
29 lines
663 B
JavaScript
"use strict";
|
|
|
|
const { validateValue } = require("@validatem/core");
|
|
const allowExtraProperties = require("@validatem/allow-extra-properties");
|
|
const isString = require("@validatem/is-string");
|
|
const forbidden = require("./");
|
|
|
|
let object = {
|
|
foo: "bar",
|
|
baz: "qux",
|
|
blub: "quz"
|
|
};
|
|
|
|
console.log(validateValue(object, [
|
|
allowExtraProperties({
|
|
foo: [ isString ]
|
|
})
|
|
])); // { foo: 'bar', baz: 'qux', blub: 'quz' }
|
|
|
|
console.log(validateValue(object, [
|
|
allowExtraProperties({
|
|
foo: [ isString ],
|
|
blub: [ forbidden ]
|
|
})
|
|
])); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At blub: Value exists in a place that should be empty
|
|
*/
|