lib/checkability/validator.rb in checkability-0.1.0 vs lib/checkability/validator.rb in checkability-0.2.0

- old
+ new

@@ -1,25 +1,25 @@ -# Checks if postcode exists in Storage -# module Checkability + # Checks if postcode comply with regex + # class Validator attr_reader :format - def initialize(conf={}) + def initialize(conf = {}) @format = conf[:format] end def check_value(checkable) result, message = _result_and_message(checkable) checkable.messages << message result end - + def _result_and_message(checkable) - if (checkable.value.gsub(' ','') =~ format[:regex]).nil? + if (checkable.value.delete(' ') =~ format[:regex]).nil? [false, "Value is not comply with format of #{format[:name]}."] else [true, "Value comply with format of #{format[:name]}."] end end end -end \ No newline at end of file +end