Custom validation keywords
Validator.addKeyword(name, definition) is used to register custom keywords with the underlying AJV instance.
It is for extending validation rules, such as isEven, maxWords, or startsWithPrefix. If you want to define reusable business field types such as tenant-id!, s('tenant-id!'), or s.tenantId('corp'), start with Custom DSL Types.
The current implementation is internally compatible with the object-based registration of AJV 8, so you can continue to use the two-parameter writing method of v1 without exposing deprecated warnings to the caller.
When to use it
For more AJV keyword definitions, please refer to the AJV official documentation.
Corresponding sample file
Example entry: add-keyword.ts
Description: Cover the minimum registration and validation path of Validator.addKeyword(), and directly display the success/failure results.