valid
Advanced tools
@@ -26,11 +26,9 @@ module Validation | ||
| def valid_value?(value) | ||
| valid = true | ||
| @params.each_pair do |key, param| | ||
| valid = false if key == :minimum && value.length < param | ||
| valid = false if key == :maximum && value.length > param | ||
| valid = false if key == :exact && value.length != param | ||
| return false if key == :minimum && (value.nil? || value.length < param) | ||
| return false if key == :maximum && !value.nil? && value.length > param | ||
| return false if key == :exact && (value.nil? || value.length != param) | ||
| end | ||
| valid | ||
| true | ||
| end | ||
@@ -37,0 +35,0 @@ |
@@ -17,13 +17,13 @@ module Validation | ||
| def valid_value?(uri_string) | ||
| begin | ||
| uri = URI(uri_string) | ||
| @required_parts.each do |part| | ||
| if uri.send(part).nil? || uri.send(part).empty? | ||
| return false | ||
| end | ||
| return true if uri_string.nil? | ||
| uri = URI(uri_string) | ||
| @required_parts.each do |part| | ||
| if uri.send(part).nil? || uri.send(part).empty? | ||
| return false | ||
| end | ||
| true | ||
| rescue ::URI::InvalidURIError => e | ||
| return false | ||
| end | ||
| true | ||
| rescue ::URI::InvalidURIError | ||
| return false | ||
| end | ||
@@ -30,0 +30,0 @@ end |
| module Validation | ||
| VERSION = '0.5.0' | ||
| VERSION = '1.0.0' | ||
| end |