mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-10 13:36:52 +03:00
feat: implement bulk validate
This commit is contained in:
13
fe-app-podkop/src/validators/bulkValidate.ts
Normal file
13
fe-app-podkop/src/validators/bulkValidate.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { BulkValidationResult, ValidationResult } from './types';
|
||||
|
||||
export function bulkValidate<T>(
|
||||
values: T[],
|
||||
validate: (value: T) => ValidationResult,
|
||||
): BulkValidationResult<T> {
|
||||
const results = values.map((value) => ({ ...validate(value), value }));
|
||||
|
||||
return {
|
||||
valid: results.every((r) => r.valid),
|
||||
results,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user