Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x 1x 1x 1x 1x 82x 83x 77x 77x 6x 6x 6x 58x 83x 83x 1x 1x 1x 24x 24x 59x 59x 59x 8x 8x 8x | import type { ValidationResult } from '@/contracts/validationResult'; export const noValidation = <T>(_: T): ValidationResult => ({ isValid: true }); export const notNull = (customErrMsg?: string) => <T>(value: T): ValidationResult => { if (value !== null) { return { isValid: true }; } return { isValid: false, errorMessage: customErrMsg ?? `Field shouldn't be empty`, }; }; export const multiValidation = <T>(...validations: Array<(validationVal: T) => ValidationResult>) => (value: T): ValidationResult => { for (const validation of validations) { const result = validation(value); if (result.isValid === false) return result; } return { isValid: true }; }; |