File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11import type { alphanumeric } from './lib/isAlphanumeric'
2- import type { ArrayValidator } from './validators/arrays'
3- import type { NumberValidator } from './validators/numbers'
4- import type { StringValidator } from './validators/strings'
52
63export interface ValidationError {
74 message : string
@@ -231,3 +228,10 @@ export interface Validator<T> {
231228 required : ( ) => Validator < T >
232229 optional : ( ) => Validator < T >
233230}
231+
232+ export interface ValidationConfig {
233+ verbose : boolean
234+ strictMode ?: boolean
235+ cacheResults ?: boolean
236+ errorMessages ?: Record < string , string >
237+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export abstract class BaseValidator<T> {
2525 return this
2626 }
2727
28- validate ( value : T ) : ValidationResult {
28+ validate ( value : T | undefined | null ) : ValidationResult {
2929 const errors : ValidationError [ ] = [ ]
3030
3131 if ( ( value === undefined || value === null ) ) {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export class DateValidator extends BaseValidator<Date> {
55 super ( )
66 this . addRule ( {
77 name : 'date' ,
8- test : ( value : unknown ) : value is Date => value instanceof Date && ! isNaN ( value . getTime ( ) ) ,
8+ test : ( value : unknown ) : value is Date => value instanceof Date && ! Number . isNaN ( value . getTime ( ) ) ,
99 message : 'Must be a valid date' ,
1010 } )
1111 }
Original file line number Diff line number Diff line change 1- import type { ValidationOptions } from './src/types'
1+ import type { ValidationConfig } from './src/types'
22
3- const config : ValidationOptions = {
3+ const config : ValidationConfig = {
44 verbose : true ,
55}
66
You can’t perform that action at this time.
0 commit comments