A collection of Regular Expressions to be used in Validations
regular_validation to your
gem 'regular_validation', '~> 0.0.2'
RegularValidation with the name of the Regular Expression in your app.
RegularValidation.username # Returns the Username Regular Expression "some_user" =~ RegularValidation.username # => 0 "1nvalid user" =~ RegularValidation.username # => nil
It's especially useful for ActiveModel Validations, however it isn't tied to Rails or any framework:
validates_format_of :username, with: RegularValidation.username validates_format_of :email, with: RegularValidation.email
Currently supports the following validations:
- Add more validations
- Add options to validations for allowing/disallowing periods, underscores, etc.
Please fork and add your regular expression validations!
Clone the repository, run the
bundle command, and then
rake to run the MiniTest specs.