poro_validator 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc2ce1f9233a5b88631a5e1f5ecb5335ac2f4a5d
4
- data.tar.gz: a57b11e741fbd0a9fa098b7f3f1836641591a1ad
3
+ metadata.gz: 734791b1e0db50920c5a04ca9ed7602008bf1ff8
4
+ data.tar.gz: 6e081d0ad53c1f08f5b1cea8219d07b415b461ad
5
5
  SHA512:
6
- metadata.gz: 653ecf3ec4b6cb90db58f483894aab76c8632f34cc5a15bacdf266817ccedf52923288b318d5155b025d9f140c1b7cccfd169ea55ef927b8a7a668161458e4f2
7
- data.tar.gz: 341ec4635211d5d825a5253d2172997d1d97fe6be5195a827c9f0d3a12916434dca46a72bd4cce1cd20e1f8f04ca04e92ad553b2385b2247b545aedcf4013e12
6
+ metadata.gz: d0e3f299a66d928b6408ff32b1ee1ee3c14939b74c2aa88c72f6971ec2c6da99b69c9c763d63dba578e638ad349512fa644a3ed04d2aef5d8df9adca05d579b1
7
+ data.tar.gz: a7bae930bad35022b4e1a5ec9fbcedf9fa8421e17b515675ed89ddb00540fe9c6705a43ae64c356672ebf60b47b9b1af379b18451ab9318c84c986fffd0368ad
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Kareem Gan
3
+ Copyright (c) 2015-2016 Kareem Gan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,12 +1,29 @@
1
- # PORO Validator #
1
+ [Gem Version]: https://badge.fury.io/rb/poro_validator
2
+ [Gem Version Badge]: https://badge.fury.io/rb/poro_validator.svg
3
+ [Build Status]: https://travis-ci.org/magicalbanana/poro_validator
4
+ [Build Status Badge]: https://travis-ci.org/magicalbanana/poro_validator.svg
5
+ [Dependency Status]: https://gemnasium.com/magicalbanana/poro_validator
6
+ [Dependency Status Badge]: https://gemnasium.com/magicalbanana/poro_validator.svg
7
+ [Code Climate]: https://codeclimate.com/github/magicalbanana/poro_validator
8
+ [Code Climate Badge]: https://codeclimate.com/github/magicalbanana/poro_validator.svg
9
+ [Coverage Report]: https://coveralls.io/github/magicalbanana/poro_validator?branch=master
10
+ [Coverage Report Badge]: https://coveralls.io/repos/magicalbanana/poro_validator/badge.svg?branch=master&service=github
11
+
12
+ [ActiveModel::Validations]: http://api.rubyonrails.org/classes/ActiveModel/Validations.html
13
+ [ActiveRecord]: http://guides.rubyonrails.org/active_record_validations.html
14
+ [S.O.L.I.D]: https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
15
+ [Single Responsibility Principle]: https://en.wikipedia.org/wiki/Single_responsibility_principle
16
+ [Ruby on Rails]: http://rubyonrails.org/
17
+ [PoroValidator]: https://github.com/magicalbanana/poro_validator
18
+ [WIKI]: https://github.com/magicalbanana/poro_validator/wiki
2
19
 
3
- [![Join the chat at https://gitter.im/magicalbanana/poro_validator](https://badges.gitter.im/magicalbanana/poro_validator.svg)](https://gitter.im/magicalbanana/poro_validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
20
+ [![Gem Version][Gem Version Badge]][Gem Version]
21
+ [![Build Status][Build Status Badge]][Build Status]
22
+ [![Dependency Status][Dependency Status Badge]][Dependency Status]
23
+ [![Code Climate][Code Climate Badge]][Code Climate]
24
+ [![Coverage Report][Coverage Report Badge]][Coverage Report]
4
25
 
5
- [![Gem Version][GV img]][Gem Version]
6
- [![Build Status][BS img]][Build Status]
7
- [![Dependency Status][DS img]][Dependency Status]
8
- [![Code Climate][CC img]][Code Climate]
9
- [![Coverage Status][CS img]][Coverage Status]
26
+ # PORO Validator #
10
27
 
11
28
  PoroValidator is a lightweight validation library for your
12
29
  **P**lain **O**ld **R**uby **O**bjects (hence PoroValidator).
@@ -427,25 +444,4 @@ The gem is available as open source under the terms of the [MIT License]
427
444
 
428
445
  ## Copyright
429
446
 
430
- Copyright (c) 2015 Kareem Gan
431
-
432
- [Gem Version]: https://badge.fury.io/rb/poro_validator
433
- [Build Status]: https://travis-ci.org/magicalbanana/poro_validator
434
- [travis pull requests]: https://travis-ci.org/magicalbanana/poro_validator/pull_requests
435
- [Dependency Status]: https://gemnasium.com/magicalbanana/poro_validator
436
- [Code Climate]: https://codeclimate.com/github/magicalbanana/poro_validator
437
- [Coverage Status]: https://coveralls.io/r/magicalbanana/poro_validator
438
-
439
- [GV img]: https://badge.fury.io/rb/poro_validator.svg
440
- [BS img]: https://travis-ci.org/magicalbanana/poro_validator.svg
441
- [DS img]: https://gemnasium.com/magicalbanana/poro_validator.svg
442
- [CC img]: https://codeclimate.com/github/magicalbanana/poro_validator.svg
443
- [CS img]: https://coveralls.io/repos/magicalbanana/poro_validator/badge.svg?branch=master&service=github
444
-
445
- [ActiveModel::Validations]: http://api.rubyonrails.org/classes/ActiveModel/Validations.html
446
- [ActiveRecord]: http://guides.rubyonrails.org/active_record_validations.html
447
- [S.O.L.I.D]: https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
448
- [Single Responsibility Principle]: https://en.wikipedia.org/wiki/Single_responsibility_principle
449
- [Ruby on Rails]: http://rubyonrails.org/
450
- [PoroValidator]: https://github.com/magicalbanana/poro_validator
451
- [WIKI]: https://github.com/magicalbanana/poro_validator/wiki
447
+ Copyright (c) 2015-2016 Kareem Gan
@@ -2,6 +2,8 @@ module PoroValidator
2
2
  module Validators
3
3
  class ExclusionValidator < RangeArrayValidator
4
4
  def validate(attribute, value, options)
5
+ return if value.nil?
6
+
5
7
  in_option = options[:in]
6
8
 
7
9
  unless validate_option(in_option)
@@ -2,6 +2,8 @@ module PoroValidator
2
2
  module Validators
3
3
  class FloatValidator < NumericValidator
4
4
  def validate(attribute, value, options)
5
+ return if value.nil?
6
+
5
7
  if is_numeric?(value.to_s, FLOAT_MATCHER)
6
8
  return
7
9
  end
@@ -2,6 +2,8 @@ module PoroValidator
2
2
  module Validators
3
3
  class InclusionValidator < RangeArrayValidator
4
4
  def validate(attribute, value, options)
5
+ return if value.nil?
6
+
5
7
  in_option = options[:in]
6
8
 
7
9
  unless validate_option(in_option)
@@ -2,6 +2,8 @@ module PoroValidator
2
2
  module Validators
3
3
  class IntegerValidator < NumericValidator
4
4
  def validate(attribute, value, options)
5
+ return if value.nil?
6
+
5
7
  if is_numeric?(value.to_s, INTEGER_MATCHER)
6
8
  return nil
7
9
  end
@@ -2,6 +2,8 @@ module PoroValidator
2
2
  module Validators
3
3
  class LengthValidator < BaseClass
4
4
  def validate(attribute, value, options)
5
+ return if value.nil?
6
+
5
7
  message = options.fetch(:message, :length)
6
8
 
7
9
  options.keys.each do |key|
@@ -13,6 +13,8 @@ module PoroValidator
13
13
  ].freeze
14
14
 
15
15
  def validate(attribute, value, options)
16
+ return if value.nil?
17
+
16
18
  unless is_numeric?(value.to_s, INTEGER_MATCHER) ||
17
19
  is_numeric?(value.to_s, FLOAT_MATCHER)
18
20
  errors.add(attribute, :integer_or_float)
@@ -1,5 +1,6 @@
1
1
  module PoroValidator
2
2
  module Validators
3
+ # @private since 0.0.1
3
4
  class RangeArrayValidator < BaseClass
4
5
  def validate_option(option)
5
6
  !option.nil? && (option.is_a?(::Range) || option.is_a?(::Array))
@@ -1,3 +1,3 @@
1
1
  module PoroValidator
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poro_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kareem Gan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler