Validator Utilities
import { Validator } from "//packages.education/agent"
// Usage: Validator.validateNumber(5);
// -- OR --
import { validateNumber } from "//packages.education/agent/utils";
// Usage: validateNumber(5);
Validator function can be used to validate the type and value of inputs. If the given value is invalid, validator functions will throw an Error.
Functions
validateBoolean(value: any)
Validates if the given value is a boolean, throws an error if it is not.
validateNumber(value: any)
Validates if the given value is a number, throws an error if it is not.
validatePositiveNumber(value: any)
Validates if the given value is a positive number, throws an error if it is not.
validateArray(value: any)
Validates if the given value is an array, throws an error if it is not.
validateFunction(value: any)
Validates if the given value is a function, throws an error if it is not.
validateColor(value: any)
Validates if the given value is a valid CSS color, throws an error if it is not.
validateModel(value: any)
Validates if the given value is a Model, throws an error if it is not.
validateAgent(value: any)
Validates if the given value is an Agent, throws an error if it is not.
validateField(value: any)
Validates if the given value is a Field, throws an error if it is not.
validateEntity(value: any)
Validates if the given value is an Entity (Agent or Field), throws an error if it is not.
validateShape(value: any)
Validates if the given value is a valid shape, throws an error if it is not.