Skip to content

psantos10/Validation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

###Validation

Code Climate Test Coverage

An extensive pack of customizable and extensible validation to your objects.

###Installation

$ gem install resize-validation
$ require 'resize-validation'

###Usage

A minimal implementation could be:

Resize::Validation::validate(email: '[email protected]')
 # => true
Resize::Validation::validate(string: 5)
# => false

raise custom exception:

Resize::Validation::validate!(integer: 'five')
# => "The input five does not match the rule integer (TypeError)"

A composable implementation could be:

  Resize::Validation::validates do |v|
    v.validate(integer: 5)
    v.validate(uppercase: "NAME")
    v.validate(boolean: false)
  end
  # => true
  Resize::Validation::validates do |v|
    v.validate(integer: "5")
    v.validate(uppercase: "NAME")
    v.validate(boolean: false)
  end
  # => false

Catching errors:

  Resize::Validation::validates! do |v|
    v.validate(integer: 5)
    v.validate(uppercase: "NAME")
    v.validate(boolean: false)
  end
  # => {:status=>true, :errors=>[]}
  Resize::Validation::validates! do |v|
    v.validate(integer: "5")
    v.validate(uppercase: "NAME")
    v.validate(boolean: false)
  end
  # => {:status=>false, :errors=>["The input 5 does not match the rule integer"]}

Rules

Numeric

Date

Types

Strings

Others

###Contributing

  1. Fork it ( https://github.com/Resize/Validation/fork )
  2. Create your feature branch (git checkout -b new_feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin new_feature)
  5. Create a new Pull Request

###License

Copyright © 2014 Londerson Araújo, released under the MIT license

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%