A library providing functions that let users validate the values in objects with YAML-formatted rules.
First of all, a list of rules in JSON / YAML format should be provided. Here is the structure of the list:
type Root = {
    condition: Condition;
    id?: number;
    errorMessage?: string;
}[]
type Condition = {
    type: string;
    field?: string;
    arg?: string | null;
    args?: (string | null)[];
    conditions?: Condition[];
}For example:
[
    {
        "condition": {
            "type": "and",
            "field": "name",
            "conditions": [
                {
                    "type": "!null"
                },
                {
                    "type": "!blank"
                }
            ]
        },
        "id": 1,
        "errorMessage": "\"name\" is required."
    },
    {
        "condition": {
            "type": "range",
            "field": "age",
            "arg": "[18"
        },
        "id": 2,
        "errorMessage": "\"age\" should be >= 18."
    }
]using Quicksilver.ObjectValidator;
Validator validator = new(File.OpenText("path/validation-rules.json"));
ValidationResult validationResult = validator.Validate(myObject);import com.quicksilver.objectvalidator.Validator;
// ...
Validator validator = new Validator(getClass().getResource("/path/validation-rules.json"));
ValidationResult validationResult = validator.Validate(myObject);import rules from "path/validation-rules.json";
import { Validator } from "@quicksilver0218/object-validator";
const validator = new Validator(rules);
const validationResult = validator.validate(myObject);