validateBatch method
Validator.validateBatch(schema, dataArray) Use the same compiled Schema to validate multiple pieces of data.
method signature
return value
Returns an array, each item is consistent with the return structure of a single validator.validate():
valid- passed or notdata- Validated data (when passed)errors- error list (on failure)
Applicable scenarios
- Batch validation before importing data
- Pre-checking a large number of records under the same schema
- I hope to compile the schema only once and then reuse it for the entire batch of data.
Corresponding sample file
Example entry: validate-batch.ts
Description: Covers Validator.validateBatch()’s single compilation, multiple data reuse, and failed item error output.