validation.ts
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -40,9 +40,9 @@ import { Result, Ok, Err, Option, None, Some } from 'space-lift'; | ||
export declare class StringValidator extends Validator<string> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], string>; | ||
} | ||
export declare class NumberValidator extends Validator<number> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], number>; | ||
} | ||
export declare class BooleanValidator extends Validator<boolean> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], boolean>; | ||
} | ||
@@ -88,12 +88,15 @@ export declare class MappedValidator<A, B> extends Validator<B> { | ||
export declare type Props = Record<string, Any>; | ||
declare type OptionalKeys<P extends Props> = { | ||
[K in keyof P]: undefined extends TypeOf<P[K]> ? K : never; | ||
}[keyof P]; | ||
declare type MandatoryKeys<P extends Props> = { | ||
[K in keyof P]: undefined extends TypeOf<P[K]> ? never : K; | ||
}[keyof P]; | ||
declare type Unpack<P extends Props> = { | ||
[K in keyof P]: P[K]['T']; | ||
}; | ||
declare type OptionalKeys<T> = { | ||
[K in keyof T]: undefined extends T[K] ? K : never; | ||
}[keyof T]; | ||
declare type MandatoryKeys<T> = { | ||
[K in keyof T]: undefined extends T[K] ? never : K; | ||
}[keyof T]; | ||
export declare type ObjectOf<P extends Props> = { | ||
[K in MandatoryKeys<P>]: TypeOf<P[K]>; | ||
[K in MandatoryKeys<Unpack<P>>]: Unpack<P>[K]; | ||
} & { | ||
[K in OptionalKeys<P>]?: TypeOf<P[K]>; | ||
[K in OptionalKeys<Unpack<P>>]?: Unpack<P>[K]; | ||
}; | ||
@@ -100,0 +103,0 @@ export declare class ObjectValidator<P extends Props> extends Validator<ObjectOf<P>> { |
@@ -40,9 +40,9 @@ import { Result, Ok, Err, Option, None, Some } from 'space-lift'; | ||
export declare class StringValidator extends Validator<string> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], string>; | ||
} | ||
export declare class NumberValidator extends Validator<number> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], number>; | ||
} | ||
export declare class BooleanValidator extends Validator<boolean> { | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], never>; | ||
validate(v: Value, _config?: Configuration, c?: Context): Result<ValidationError[], boolean>; | ||
} | ||
@@ -88,12 +88,15 @@ export declare class MappedValidator<A, B> extends Validator<B> { | ||
export declare type Props = Record<string, Any>; | ||
declare type OptionalKeys<P extends Props> = { | ||
[K in keyof P]: undefined extends TypeOf<P[K]> ? K : never; | ||
}[keyof P]; | ||
declare type MandatoryKeys<P extends Props> = { | ||
[K in keyof P]: undefined extends TypeOf<P[K]> ? never : K; | ||
}[keyof P]; | ||
declare type Unpack<P extends Props> = { | ||
[K in keyof P]: P[K]['T']; | ||
}; | ||
declare type OptionalKeys<T> = { | ||
[K in keyof T]: undefined extends T[K] ? K : never; | ||
}[keyof T]; | ||
declare type MandatoryKeys<T> = { | ||
[K in keyof T]: undefined extends T[K] ? never : K; | ||
}[keyof T]; | ||
export declare type ObjectOf<P extends Props> = { | ||
[K in MandatoryKeys<P>]: TypeOf<P[K]>; | ||
[K in MandatoryKeys<Unpack<P>>]: Unpack<P>[K]; | ||
} & { | ||
[K in OptionalKeys<P>]?: TypeOf<P[K]>; | ||
[K in OptionalKeys<Unpack<P>>]?: Unpack<P>[K]; | ||
}; | ||
@@ -100,0 +103,0 @@ export declare class ObjectValidator<P extends Props> extends Validator<ObjectOf<P>> { |
{ | ||
"name": "validation.ts", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Validation for TypeScript", | ||
@@ -9,5 +9,7 @@ "license": "MIT", | ||
"typings": "commonjs/validation.d.ts", | ||
"dependencies": { | ||
"space-lift": ">=0.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -17,4 +19,5 @@ "chalk": "1.1.1", | ||
"mocha": "2.2.5", | ||
"typescript": "3.0.3" | ||
"typescript": "3.1.1" | ||
}, | ||
"scripts": { | ||
@@ -21,0 +24,0 @@ "build": "npm run build-es && npm run build-commonjs", |
79923
1586