Hi,
I have requirement to validate 4-digit pin. Below are the requirement of the 4-digit number
1. pin should not allow sequential numbers
2. pin should not allow same numbers
example: 1234 or 4321 or 0000, 1111 or 4444 or 2222 or 3333 numbers are not allowed as a card pin.
can anyone please help me how to write logic for the validation.
thanks in advance!
Discussion posts and replies are publicly visible
A first idea here. Not sure if it catches all edge cases.
a!localVariables( local!pins: {"7369", "1234", "4321", "0000", "1111", "4444", "2222", "3333"}, a!forEach( items: local!pins, expression: and( fv!item <> concat(tointeger(left(fv!item, 1)) + enumerate(4)), /* positive sequence */ fv!item <> concat(tointeger(left(fv!item, 1)) + enumerate(4) * -1), /* negative sequence */ fv!item <> rept(mid(fv!item, 1, 1), 4), /* 4 times the first character */ fv!item <> rept(mid(fv!item, 2, 1), 4), /* 4 times the second character */ fv!item <> rept(mid(fv!item, 3, 1), 4), /* 4 times the third character */ fv!item <> rept(mid(fv!item, 4, 1), 4) /* 4 times the fourth character */ ) ) )