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
Hi Druva,
Please try the below code. Here rule input (ri!pin) is of type text
if( and( len(ri!pin)=4, len(tostring(tointeger(ri!pin)))=len(ri!pin) ), a!localVariables( local!numbersUsed:{ int(charat(ri!pin,1)), int(charat(ri!pin,2)), int(charat(ri!pin,3)), int(charat(ri!pin,4)) }, if( length(union(local!numbersUsed,local!numbersUsed))<>length(local!numbersUsed), "numbers cannot be repeated in pin", if( and( local!numbersUsed[1]+1=local!numbersUsed[2], local!numbersUsed[2]+1=local!numbersUsed[3], local!numbersUsed[3]+1=local!numbersUsed[4], ), "cannot be sequentail numbers", "no error" ) ) ), "pin should be 4 characters and should contain only numbers" )