Creates an object checker for a value or for a named field within a parent object.
When both key and data are provided, the checker reads data[key].
ProtectedkeyProtecteddataProtectedhas_Protectedis_Protectedcheck_Protectedknown_ProtectedoutStaticforRequires the value to exist and contain at least one key.
Optionaloptions: CheckOptionsRequires the value to be a non-array object.
This check runs automatically during construction when a value is present.
Optionaloptions: CheckOptionsReturns a checker for a required field and marks that field as known.
Known fields are used later by noExtraFields.
Optionaloptions: CheckOptionsReturns a checker for an optional field and marks that field as known.
Returns a field checker that becomes required only when condition passes.
The condition receives the current object value.
Optionaloptions: CheckOptionsFails when the input contains keys that were not declared through required, optional, or conditional.
The extra-field check is evaluated when result is called.
Optionaloptions: CheckOptionsProtectedrulesRuns a group of field or nested checks and merges their results.
Return an array of checks from the callback. Each check can be synchronous or a promise.
Alias for check using JSON Schema-style naming.
All returned checks must pass for the composed result to stay valid.
Evaluates alternative branches and succeeds when at least one branch is valid.
Each branch function is evaluated in isolation using cloned object state. Valid branches are then replayed on the current checker so mutations behave the same way as normal non-branch checks.
Evaluates alternative branches and succeeds only when exactly one branch is valid.
Each branch function is evaluated in isolation using cloned object state. The single winning branch is then replayed on the current checker so mutations behave the same way as normal non-branch checks.
Inverts a composed object branch and fails when that branch is valid.
The negated branch is evaluated in isolation and is never replayed onto the current checker, so mutations inside the branch do not affect the original input.
Optionaloptions: CheckOptionsValidates the current object value against a class definition. *
Optionaloptions: ClassValidationOptionsApplies a custom predicate to the current object value.
When the predicate returns false, the result contains Custom check failed
unless custom check options override the message or code.
Optionaloptions: CheckOptionsProtectederrorOptionaloptions: CheckOptionsMerges a prior result into this checker when that prior result is invalid.
This is useful when composing validations from external sources.
Returns the validation result for the current object.
With no options, this returns the raw internal result structure. With options, the output is formatted through the package result helpers.
Optionaloptions: ResultOptions
Validates object-shaped input and coordinates checks for its fields.
Use this class when the input should be an object and individual fields need their own validation rules.
Example