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