Groups

# Four digit PIN validation

 FOUR DIGIT PIN VALIDATION RULES    *Four numeric characters (not valid: 21AR)    *Zero not allowed (not valid: 5023)    *Up to 2 repeated consecutive values (not valid: 3888)    *Up to 3 sequencial numeric values in AZ or ZA order (not valid: 1234, 5432) ```&NbrPIN C4 &Result C1 &Cdor N2.0 &xIdx N2.0 &yIdx N2.0 parm(&NbrPIN ,&Result ) ; &Result = nullvalue(&Result ) /* PIN Lenght (4 characters) */ IF len(&NbrPIN ) <> 4 &Result = 'E' return ENDIF /* Numeric charaters (1-9 only,0 not allowed) */ &Cdor = 0 &xIdx = 0 Do while &xIdx < 4 &xIdx = &xIdx 1 IF substr(&NbrPIN ,&xIdx ,1) < '1' .OR. substr(&NbrPIN ,&xIdx ,1) > '9' &Cdor = &Cdor 1 ENDIF Enddo IF &Cdor > 0 &Result = 'E' return ENDIF //* Up to 2 repeated consecutive numbers */ &Cdor = 0 &xIdx = 1 Do while &xIdx < 4 &xIdx = &xIdx 1 &yIdx = &xIdx -1 IF substr(&NbrPIN ,&xIdx ,1) = substr(&NbrPIN ,&yIdx , 1) IF &Cdor = 0 &Cdor = &Cdor 1 ENDIF &Cdor = &Cdor 1 ENDIF Enddo IF &Cdor > 2 &Result = 'E' return ENDIF /* Up to 3 sequential numbers (ascendent) */ &Cdor = 0 &xIdx = 1 Do while &xIdx < 4 &xIdx = &xIdx 1 &yIdx = &xIdx -1 IF val(substr(&NbrPIN ,&xIdx , 1)) = val(substr(&NbrPIN ,&yIdx ,1)) 1 IF &Cdor = 0 &Cdor = &Cdor 1 ENDIF &Cdor = &Cdor 1 ENDIF Enddo IF &Cdor > 3 &Result = 'E' return ENDIF /* Up to 3 sequential numbers (descendent) */ &Cdor = 0 &xIdx = 1 Do while &xIdx < 4 &xIdx = &xIdx 1 &yIdx = &xIdx -1 IF val(substr(&NbrPIN ,&xIdx , 1)) 1 = val(substr(&NbrPIN ,&yIdx , 1)) IF &Cdor = 0 &Cdor = &Cdor 1 ENDIF &Cdor = &Cdor 1 ENDIF Enddo IF &Cdor > 3 &Result = 'E' return ENDIF ```

 Created: 20 April 2005 10:34 AM by lrocha Last update: 20 April 2005 10:34 AM by lrocha