Method: BsnValidator.validate_bsn

Defined in:
lib/elfproef/bsn_validator.rb

.validate_bsn(value, options = {}) ⇒ Object

A BSN is an 8 or 9 digit Dutch social security number.



15
16
17
18
19
20
21
22
23
# File 'lib/elfproef/bsn_validator.rb', line 15

def self.validate_bsn(value, options = {})
  bsn = value.to_s.gsub(/\D/, '').strip

  # Only allow 8 or 9 digits
  return false if bsn.length < 8 || bsn.length > 9

  # Validate with the advanced eleven test
  self.validate_with_advanced_eleven_test(bsn)
end