Functions
@system-inc/base-foundation · 515c140 · 4 symbols
findValidationTargetByName
Find a registered class constructor by its name.
Used by the CLI when emitting GraphQL schema metadata: we have a type name string (the GraphQL input type) and need to resolve it to the corresponding TypeScript class so we can read its rules.
Returns undefined when no registered target matches.
getValidationRules
Return every rule registered against target and its ancestors,
in the public shape that omits internal callbacks.
registerRule
Creates a property decorator for a validation rule.
The returned factory is callable (VerifyIsEmail() / VerifyMaxLength(255))
and also exposes a .check() predicate for ad-hoc use:
Usage:
validate
Validates a value against the rules attached to its class and any nested validatable classes it contains.
Behavior:
- Deep by default. Any property whose value is a class instance with registered rules is validated recursively. Same for arrays of such instances. Callers never need to annotate nested types.
- Arrays are declared, then value rules iterate. An array-typed
property must carry an array-level rule (
operatesOn: 'array'— e.g.IsArray,ArrayMinSize), which receives the whole array. Only then do value-level rules apply per-element (error paths include the index,items[2].email). Without an array-level rule a value rule evaluates the value itself, so an array on a scalar property is rejected rather than silently iterated. IsOptionalshort-circuits. When a property carries@VerifyIsOptional()and its value isnull/undefined, all other rules on the property are skipped.- Cycles are safe. A visited set prevents infinite recursion through self-referential object graphs.
Returns a flat array of ValidationError. An empty array means the value passed validation.