check

Apply multiple validation functions to a value

Parameters

  1. funcs: Function:  
    Validation function to apply

Example

const isRequired = check(exists("It should exist"))
isRequired("value")

checkWrapper

Helper wrapper for creating validation function

Parameters

  1. func: Function (=()=>true):  
    Function used for validation

Example

function longerThanFive(msg) {
 return checkWrapper(val => val.length > 5)(msg)
}

exists

Check if value exists

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

empty

Check if value does not exist

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

bool

Check if value is Boolean

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

int

Check if value is Integer

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

num

Check if value is Number

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

str

Check if value is String

Parameters

  1. msg: String?:  
    Message when validation fails

Returns

pattern

Check if value matches given regex pattern

Parameters

  1. pattern: RegExp:  
  2. msg: String?:  
    Message when validation fails

Returns

Example

check(pattern(/foo/), exists())

exact

Parameters

  1. val: any:  
  2. msg: any: