import Context from '../ctx' ; export const isABoolean = x => typeof x == 'boolean' ; export const isNotABoolean = x => ! isABoolean ( x ) ; /**
 * Boolean
 */ export default class BooleanContext < Maybe = boolean > extends Context < boolean | Maybe > { public readonly name = 'Boolean' ; constructor ( optional = false , nullable = false ) { super ( optional , nullable ) ; this . push ( v => isNotABoolean ( v ) ? new Error ( 'must-be-a-boolean' ) : true ) ; } public makeOptional ( ) { return new BooleanContext ( true , false ) ; } public makeNullable ( ) { return new BooleanContext ( false , true ) ; } public makeOptionalNullable ( ) { return new BooleanContext ( true , true ) ; } }