Sha256: d7d32488542f30ef636312875002da976ab27881353ff16257ab00557e6cc0f8
Contents?: true
Size: 597 Bytes
Versions: 2
Compression:
Stored size: 597 Bytes
Contents
module Checkability # Checks if postcode comply with regex # class Validator attr_reader :format 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.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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
checkability-0.3.0 | lib/checkability/validator.rb |
checkability-0.2.0 | lib/checkability/validator.rb |