Module: ValidateFormat
- Included in:
- Dixon::Validators::Taiwan
- Defined in:
- lib/dixon/validators/taiwan.rb
Constant Summary collapse
- TAIWAN_ID_REGEXP =
/[a-zA-Z][1|2][0-9]+/i
Instance Method Summary collapse
-
#valid_format?(id) ⇒ Boolean
Check if given id’s format is valid.
Instance Method Details
#valid_format?(id) ⇒ Boolean
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.
112 113 114 115 116 |
# File 'lib/dixon/validators/taiwan.rb', line 112 def valid_format?(id) return true if id =~ TAIWAN_ID_REGEXP and id.size == 10 puts 'Invalid ID number.' false end |