Skip to content

Commit bab722f

Browse files
chore: lint and types
1 parent 00e4e56 commit bab722f

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import 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

63
export 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+
}

src/validators/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)) {

src/validators/dates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

validation.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

0 commit comments

Comments
 (0)