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.
21 lines
400 B
21 lines
400 B
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;
|
|
|