Sha256: 50278ab4b0111b516a51f3166845a5c5815c1171bc4d7b68ac21ba61b256fead
Contents?: true
Size: 525 Bytes
Versions: 2
Compression:
Stored size: 525 Bytes
Contents
module NxtSchema module Validators class Pattern < Validator def initialize(pattern) @pattern = pattern end register_as :pattern, :format attr_reader :pattern def build lambda do |application, value| if value.match(pattern) true else message = translate_error(application.locale, value: value, pattern: pattern) application.add_error(message) false end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nxt_schema-1.0.1 | lib/nxt_schema/validators/pattern.rb |
nxt_schema-1.0.0 | lib/nxt_schema/validators/pattern.rb |