Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CustomValidators {
- static OIB_VALIDATOR = { String value ->
- if (!(value =~ /^[0-9]{11}$/)) {
- return false
- }
- Integer a = 10;
- 10.times {
- a += (value[it] as Integer)
- a %= 10
- a = (a == 0 ? 10 : a)
- a *= 2
- a %= 11
- }
- def checkDigit = 11 - a
- checkDigit = (checkDigit == 10 ? 0 : checkDigit)
- return checkDigit == (value[-1] as Integer)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement