Repository URL to install this package:
Version:
0.14.1 ▾
|
// import { size } from 'chain-able-boost'
const DEFAULT_MIN = 0
const DEFAULT_MAX = 100
function isValidLength(
value: number | string,
minLength: number = DEFAULT_MIN,
maxLength: number = DEFAULT_MAX
): boolean {
const length = String(value).length
return length > minLength && length < maxLength
}
// | ValidMap | ValidSet < handled by size bu tned to import
type ValidValue = number | string | Array<any> | Object
function isValidLengthCurried(
minLength: number = DEFAULT_MIN,
maxLength: number = DEFAULT_MAX
) {
return function isValidLengthCurriedValue(value: ValidValue) {
return isValidLength(value, minLength, maxLength)
}
}
export { isValidLength, isValidLengthCurried }
export default isValidLength