Library to validate:
- date
- date_time
- ip address
- mac address
Installation
Add this line to your application's Gemfile:
gem 'universal_validators'
And then execute:
$ bundle
Or install it yourself as:
$ gem install universal_validators
Usage
Date validation:
date = UniversalValidators::DateValidator.new('2015-02-25')
date.valid?
=> true
DateTime validation:
date_time = UniversalValidators::DateTimeValidator.new('2015-02-25 12:33')
date_time.valid?
=> true
Ip address validation (without netmask):
ip = UniversalValidators::IpValidator.new('127.0.0.1')
ip.valid?
=> true
Ip address validation (with netmask):
ip = UniversalValidators::IpValidator.new('127.0.0.1/32', true)
ip.valid?
=> true
Mac address validation:
mac = UniversalValidators::MacAddressValidator.new('00:0A:CD:00:CC:FE')
mac.valid?
=> true
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request