Private applyPrivate Applies validation rules to a field value.
Cleans validation syntax from JSON object keys.
This method recursively processes a JSON object and removes validation syntax markers (?, *, :rules) from all object keys. This is useful when AI models mistakenly include our validation syntax in their responses.
The JSON data to clean
A new object with cleaned keys, typed as T
interface MyData {
name: string;
items: string[];
config: { enabled: boolean };
}
const dirtyJson = {
"name?": "John",
"items:[1+]": ["a", "b"],
"config*": { "enabled?": true }
};
const cleanJson = validator.cleanValidationSyntax<MyData>(dirtyJson);
// Result is typed as MyData
Private parsePrivate parseValidates an object against a template with validation rules.
The data object to validate
The template object with validation rules
The current path in the object hierarchy (used internally)
ValidationResult with Success flag and any validation errors
Validates an object against a JSON schema string. Convenience method that parses the schema and validates.
The data to validate
JSON string containing the validation schema
ValidationResult with Success flag and any validation errors
Private validatePrivate Validates array length constraints.
Private validatePrivate Validates non-empty constraint.
Private validatePrivate Validates an object against a template recursively.
Private validatePrivate Validates type constraints.
Lightweight JSON validator with flexible validation rules.
Example