import isValid from 'date-fns/is_valid' ; import parseDate from 'date-fns/parse' ; export const isNumeric = ( value ) => ! isNaN ( parseFloat ( value ) ) && isFinite ( value ) ; export const valuesAreNumeric = ( values ) => values . every ( isNumeric ) ; export const isInteger = ( value ) => Number . isInteger ( value ) || ! isNaN ( parseInt ( value ) ) ; export const valuesAreInteger = ( values ) => values . every ( isInteger ) ; export const isBoolean = ( value ) => typeof value === 'boolean' ; export const valuesAreBoolean = ( values ) => values . every ( isBoolean ) ; export const isBooleanString = ( value ) => [ 'true' , 'false' ] . includes ( value . toString ( ) . toLowerCase ( ) ) ; export const valuesAreBooleanString = ( values ) => values . every ( isBooleanString ) ; export const isString = ( value ) => typeof value === 'string' ; export const valuesAreString = ( values ) => values . every ( isString ) ; const HtmlRegexp = /<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)<\/\1>/i ; export const isHtml = ( value ) => ! value || HtmlRegexp . test ( value ) ; export const valuesAreHtml = ( values ) => values . every ( isHtml ) ; const UrlRegexp = /http(s*):\/\/.*/i ; export const isUrl = ( value ) => ! value || UrlRegexp . test ( value ) ; export const valuesAreUrl = ( values ) => values . every ( isUrl ) ; const ImageUrlRegexp = /http(s*):\/\/.*\.(jpeg|jpg|jfif|pjpeg|pjp|png|svg|gif|webp|apng|bmp|ico|cur|tif|tiff)/i ; export const isImageUrl = ( value ) => ! value || ImageUrlRegexp . test ( value ) ; export const valuesAreImageUrl = ( values ) => values . every ( isImageUrl ) ; const EmailRegexp = /@{1}/ ; export const isEmail = ( value ) => ! value || EmailRegexp . test ( value ) ; export const valuesAreEmail = ( values ) => values . every ( isEmail ) ; export const isArray = ( value ) => Array . isArray ( value ) ; export const valuesAreArray = ( values ) => values . every ( isArray ) ; export const isDate = ( value ) => ! value || value instanceof Date ; export const valuesAreDate = ( values ) => values . every ( isDate ) ; export const isDateString = ( value ) => ! value || ( typeof value === 'string' && isValid ( parseDate ( value ) ) ) ; export const valuesAreDateString = ( values ) => values . every ( isDateString ) ; export const isObject = ( value ) => Object . prototype . toString . call ( value ) === '[object Object]' ; export const valuesAreObject = ( values ) => values . every ( isObject ) ;