Posted By

pasza on 06/07/11


Tagged

number polish pesel


Versions (?)

pesel


 / Published in: Groovy
 

  1. class PolishNumberValidator {
  2.  
  3. def String value;
  4.  
  5. private static final int[] peselWeight = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7]
  6.  
  7. def isPesel() {
  8. if (StringUtils.isBlank(value)) {
  9. }
  10. if (! (value =~ /^\d{11}$/) ) {
  11. }
  12.  
  13.  
  14. int sum = 0
  15. peselWeight.eachWithIndex {val, i ->
  16. sum += val*(value[i] as int)
  17. }
  18. return sum % 10 == (value[10] as int)
  19. }
  20. }

Report this snippet  

You need to login to post a comment.