Example #1
0
 aNumber: function isNumber (val) {
   if (!isNumber(val)) {
     throw new Error(String(val) + 'is not a number')
   }
 },
Example #2
0
 notANumber: function isNotNumber (val) {
   if (isNumber(val)) {
     throw new Error(String(val) + ' is a number')
   }
 },
Example #3
0
////////////////////////////////////////////////////////////////////////////////
// REQUIRES : END
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// CASTS
////////////////////////////////////////////////////////////////////////////////

const CASTS = {

  //////////////////////////////////////////////////////////////////////////////
  // STRING
  //////////////////////////////////////////////////////////////////////////////

  [Type.STRING] (v) {
    if (isString(v) || isNumber(v) || isBoolean(v) || isDate())
      return v.toString();

    return CAST_ERROR;
  },

  //////////////////////////////////////////////////////////////////////////////
  // STRING NOT EMPTY TRIMMED
  //////////////////////////////////////////////////////////////////////////////

  [Type.STRING_NET] (v) {
    let res = CASTS[Type.STRING](v);

    if (res === CAST_ERROR)
      return res;