You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
400 B
22 lines
400 B
2 years ago
|
const testLength: (
|
||
|
args: Pick<MinimalInputTestArgs, 'value'> &
|
||
|
Partial<Pick<MinimalInputTestArgs, 'max' | 'min'>>,
|
||
|
) => boolean = ({ max, min, value }) => {
|
||
|
const { length } = String(value);
|
||
|
|
||
|
let isGEMin = true;
|
||
|
let isLEMax = true;
|
||
|
|
||
|
if (min) {
|
||
|
isGEMin = length >= min;
|
||
|
}
|
||
|
|
||
|
if (max) {
|
||
|
isLEMax = length <= max;
|
||
|
}
|
||
|
|
||
|
return isGEMin && isLEMax;
|
||
|
};
|
||
|
|
||
|
export default testLength;
|