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.

22 lines
591 B
JavaScript

"use strict";
const { validateValue } = require("@validatem/core");
const isString = require("@validatem/is-string");
const wrapPath = require("./");
let fakePath = [ "some", "fake", "path" ];
let rule = wrapPath(fakePath, {
someProperty: [ isString ]
});
let objectA = { someProperty: "hello world" };
console.log(validateValue(objectA, [ rule ])); // hello world
let objectB = { someProperty: 42 };
console.log(validateValue(objectB, [ rule ])); /*
AggregrateValidationError: One or more validation errors occurred:
- At some -> fake -> path -> someProperty: Must be a string
*/