module ValidateFormat
Constants
- TAIWAN_ID_REGEXP
A123456789
Public Instance Methods
validate_id_format(id)
click to toggle source
Check if given id’s format is valid. The current ID number has exact 10 digits The first digit is one capital English letter and is followed by nine Arabic numerals. returns
'Empty ID.' for empty string 'Valid ID.' if the format is correct. otherwise, 'Invalid ID number.'
# File lib/dixon/validators/taiwan.rb, line 131 def validate_id_format(id) id_str = id.to_s return 'Empty ID.' if id_str.empty? return 'Valid ID.' if id_str =~ TAIWAN_ID_REGEXP and id_str.size == 10 return Dixon::Validators::Taiwan::INVALID_MESSAGE end