mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 20:16:53 +03:00
14 lines
336 B
TypeScript
14 lines
336 B
TypeScript
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,
|
|
};
|
|
}
|