type Value = any ; /**
 * Check if the value is a string.
 */ const testIsString = ( value ) : boolean => typeof value === 'string' || value instanceof String ; /**
 * Check if the value is a number.
 */ const testIsNumber = ( value ) : boolean => typeof parseFloat ( value ) === 'number' && ! isNaN ( parseFloat ( value ) ) && ! isNaN ( value ) ; /**
 * Check if the value is null or undefined.
 */ const testIsNullOrUndefined = ( value ) : boolean => value === null || value === undefined ; /**
 * Check if the value is empty.
 */ const testIsEmpty = ( value ) : boolean => value === '' || testIsNullOrUndefined ( value ) ; const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i ; returns { function } export const isRequired = ( ) => ( value ) : boolean => ! ! value || value === 0 ; /**
 * Check if the value is a string and is not empty.
 */ export const isNotEmptyString = ( ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; if ( ! testIsString ( value ) ) return false ; return ! ! ( value || '' ) . match ( /^(?!\s*$).+/ ) ; } ; /**
 * Check if the value is an array and is not empty.
 */ export const isNotEmptyArray = ( ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; if ( ! Array . isArray ( value ) ) return false ; return ! ! ( value || [ ] ) . length ; } ; /**
 * Check if the value is a valid email.
 */ export const isEmail = ( ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; if ( ! testIsString ( value ) ) return false ; return ! value || emailRegex . test ( value ) ; } ; /**
 * Check if the value is a number.
 */ export const isNumber = ( ) => ( value ) : boolean => testIsEmpty ( value ) || testIsNumber ( value ) ; /**
 * Check if the value is greater than the given minimum.
 */ export const isMinNumber = ( min ) => ( value ) : boolean => testIsEmpty ( value ) || ( testIsNumber ( value ) && parseFloat ( value ) >= min ) ; /**
 * Check if the value is lower than the given maximum.
 */ export const isMaxNumber = ( max ) => ( value ) : boolean => testIsEmpty ( value ) || ( testIsNumber ( value ) && parseFloat ( value ) <= max ) ; /**
 * Check if the value is between the minimum and the maximum.
 */ export const isInRangeNumber = ( min , max ) => ( value ) : boolean => ( testIsEmpty ( value ) || ( testIsNumber ( value ) && parseFloat ( value ) >= min && parseFloat ( value ) <= max ) ) ; /**
 * Check if the value is a percentage, between 0 and 100.
 */ export const isPercentage = ( ) => ( value ) : boolean => testIsEmpty ( value ) || ( testIsNumber ( value ) && parseFloat ( value ) >= 0 && parseFloat ( value ) <= 100 ) ; /**
 * Check if the value has the given length.
 */ export const isLength = ( length ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; return ( testIsString ( value ) || Array . isArray ( value ) ) && value . length === length ; } ; /**
 * Check if the value has a length greater than the given minimum.
 */ export const isMinLength = ( min ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; return ( testIsString ( value ) || Array . isArray ( value ) ) && value . length >= min ; } ; /**
 * Check if the value has a length lower than the given maximum.
 */ export const isMaxLength = ( max ) => ( value ) : boolean => testIsEmpty ( value ) || ( ( testIsString ( value ) || Array . isArray ( value ) ) && value . length <= max ) ; /**
 * Check if the value has match a REGEX pattern.
 */ export const isPattern = ( pattern ) => ( value ) : boolean => { if ( testIsEmpty ( value ) ) return true ; const regex = new RegExp ( pattern , 'g' ) ; return ( testIsString ( value ) && regex . test ( value ) ) ; } ;