advanced code snippet search
pasza on 06/07/11
number polish pesel
06/07/11 08:46pm
class PolishNumberValidator { def String value; private static final int[] peselWeight = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7] def isPesel() { if (StringUtils.isBlank(value)) { return false } if (! (value =~ /^\d{11}$/) ) { return false } int sum = 0 peselWeight.eachWithIndex {val, i -> sum += val*(value[i] as int) } return sum % 10 == (value[10] as int) }}
Report this snippet Tweet
Comment:
You need to login to post a comment.