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 29 30 31 32 33 34 35 36 37 38 39 40 41 | 13x 13x 1x 2x 1x 2x | import { Nullable } from '../types' import { isBoolean } from '../utils' import { VaeLocale, VaeLocaleMessage } from './VaeLocale' import { VaeSchema } from './VaeSchema' export class VaeBooleanSchema< T0 extends Nullable<boolean> = boolean, > extends VaeSchema<T0> { constructor(message: VaeLocaleMessage = VaeLocale.boolean.type) { super({ type: 'boolean', }) this.transform(Boolean as any).check({ fn: isBoolean, message: message, }) } /** * 应为 true */ true(message: VaeLocaleMessage = VaeLocale.boolean.true) { return this.check({ fn: v => v === true, message: message, tag: 'true', }) } /** * 应为 false */ false(message: VaeLocaleMessage = VaeLocale.boolean.false) { return this.check({ fn: v => v === false, message: message, tag: 'false', }) } } |