Repository URL to install this package:
|
Version:
3.7.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 | any[] | { [key: string]: any }
function isValidLengthCurried(
minLength: number = DEFAULT_MIN,
maxLength: number = DEFAULT_MAX
) {
return function isValidLengthCurriedValue(value: ValidValue) {
return isValidLength(value as string, minLength, maxLength)
}
}
export { isValidLength, isValidLengthCurried }
export default isValidLength