export function throwNull2NonNull ( field , d ) { return errorHelper ( field , d , 'non-nullable object' , false ) ; } export function throwNotObject ( field , d , nullable ) { return errorHelper ( field , d , 'object' , nullable ) ; } export function throwIsArray ( field , d , nullable ) { return errorHelper ( field , d , 'object' , nullable ) ; } export function checkNumber ( d , nullable , field ) { if ( typeof d !== 'number' && ( ! nullable || ( nullable && d !== null && d !== undefined ) ) ) { errorHelper ( field , d , 'number' , nullable ) ; } } export function checkBoolean ( d , nullable , field ) { if ( typeof d !== 'boolean' && ( ! nullable || ( nullable && d !== null && d !== undefined ) ) ) { errorHelper ( field , d , 'boolean' , nullable ) ; } } export function checkString ( d , nullable , field ) { if ( typeof d !== 'string' && ( ! nullable || ( nullable && d !== null && d !== undefined ) ) ) { errorHelper ( field , d , 'string' , nullable ) ; } } export function errorHelper ( field , d , type , nullable ) { if ( nullable ) { type += ', null, or undefined' ; } throw new TypeError ( 'Expected ' + type + ' at ' + field + ' but found:\n' + JSON . stringify ( d ) ) ; }