项目作者: dbackowski

项目描述 :
Library to validate: date, date_time, ip address, mac address
高级语言: Ruby
项目地址: git://github.com/dbackowski/universal_validators.git
创建时间: 2015-02-25T13:22:30Z
项目社区:https://github.com/dbackowski/universal_validators

开源协议:MIT License

下载


UniversalValidators Build Status

Library to validate:

  • date
  • date_time
  • ip address
  • mac address

Installation

Add this line to your application’s Gemfile:

  1. gem 'universal_validators'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install universal_validators

Usage

Date validation:

  1. date = UniversalValidators::DateValidator.new('2015-02-25')
  2. date.valid?
  3. => true

DateTime validation:

  1. date_time = UniversalValidators::DateTimeValidator.new('2015-02-25 12:33')
  2. date_time.valid?
  3. => true

Ip address validation (without netmask):

  1. ip = UniversalValidators::IpValidator.new('127.0.0.1')
  2. ip.valid?
  3. => true

Ip address validation (with netmask):

  1. ip = UniversalValidators::IpValidator.new('127.0.0.1/32', true)
  2. ip.valid?
  3. => true

Mac address validation:

  1. mac = UniversalValidators::MacAddressValidator.new('00:0A:CD:00:CC:FE')
  2. mac.valid?
  3. => true

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request