@expandorg/validation
Advanced tools
Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "@expandorg/validation", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Expand UI validation library", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "b6fed2baf6724c76051ae84f7ffc3d1e6edf3616" | ||
"gitHead": "14a9fc49f391eebb06f22532147de5abda332ff9" | ||
} |
@@ -12,4 +12,38 @@ // @flow | ||
isRequiredArray: (value: any) => !!value && value.length > 0, | ||
isMinCharacterCount: (value: any, min: number) => { | ||
if (typeof value !== 'string') { | ||
return false; | ||
} | ||
return value.length >= min; | ||
}, | ||
isMaxCharacterCount: (value: any, max: number) => { | ||
if (typeof value !== 'string') { | ||
return false; | ||
} | ||
return value.length <= max; | ||
}, | ||
isGreater: (value: any, b: number) => { | ||
const v = +value; | ||
return v > b; | ||
}, | ||
isGreaterOrEqual: (value: any, a: number) => { | ||
if (!rules.isNumber(value)) { | ||
return false; | ||
} | ||
return +value >= a; | ||
}, | ||
isLess: (value: any, a: number) => { | ||
if (!rules.isNumber(value)) { | ||
return false; | ||
} | ||
return +value < a; | ||
}, | ||
isLessOrEqual: (value: any, a: number) => { | ||
if (!rules.isNumber(value)) { | ||
return false; | ||
} | ||
return +value <= a; | ||
}, | ||
}; | ||
export default rules; |
19818
83