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.
24 lines
471 B
24 lines
471 B
2 years ago
|
import { MinimalInputTestArgs } from '../../types/TestInputFunction';
|
||
|
|
||
|
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;
|