/**
 * Helper functions for validating input.
 */ export class ValidationHelper { param name param param public static isEmpty ( name , param ) { if ( param === undefined || param === null ) { throw new Error ( `The parameter '${ name }' has an invalid value, it can not be empty.` ) ; } } param name param str param err public static string ( name , str ? , err ? ) { if ( typeof ( str ) !== "string" || str . trim ( ) . length === 0 ) { throw new Error ( err ? err : `The parameter '${ name }' is not defined or not a string.` ) ; } } param name param num public static number ( name , num ) { if ( typeof num !== "number" ) { throw new TypeError ( `The parameter '${ name }' is not defined or not a number.` ) ; } } param name param b public static boolean ( name , b ) { if ( typeof b !== "boolean" ) { throw new TypeError ( `The parameter '${ name }' is not defined or not a boolean.` ) ; } } param name param arr public static array ( name , arr ) { if ( ! ( Array . isArray ( arr ) ) ) { throw new TypeError ( `The parameter '${ name }' is not defined or not an array.` ) ; } } param name param val param options public static oneOf ( name , val , options ) { if ( ! options . includes ( val ) ) { throw new Error ( `The parameter '${ name }' should be one of [${ options . join ( ", " ) }].` ) ; } } }