parent
c4a04ddbae
commit
2d6766f096
3 changed files with 26 additions and 3 deletions
@ -0,0 +1,23 @@ |
||||
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; |
Loading…
Reference in new issue