Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Valid:
- Something, Foobar 111.
- Invalid:
- .......
- validate :yourvalue_must_contain_at_least_3_alphabetic_characters
- protected
- def yourvalue_must_contain_at_least_3_alphabetic_characters
- unless yourvalue.gsub(/[^A-Z]/i,"").size > 2
- errors.add(:yourvalue, 'should have at least 3 alphabetic characters')
- end
- end
- validates_format_of :password, :with => /([^a-zA-Z]*([a-zA-Z]+)[^a-zA-Z]*){3,}/
- protected
- def validate
- unless your_field.gsub(/[^A-Z]/i,"").size > 2
- errors.add("your_field", "Must contain at least 3 alphabetical characters")
- end
- end
Add Comment
Please, Sign In to add comment