Sha256: f604a4b292838d37ddf57976cf8f1a93edd53e04169c83c31e816d74acabacc3
Contents?: true
Size: 591 Bytes
Versions: 2
Compression:
Stored size: 591 Bytes
Contents
module LIVR class AliasedRule def initialize(_alias) raise "Alias name required" unless _alias["name"] raise "Alias rules required" unless _alias["rules"].present? @alias = _alias @validator = Validator.new(value: Array.wrap(@alias["rules"])) end def new(*args) self end def call(value, user_data, field_results) result = @validator.validate({ value: value }) if result field_results << result[:value] return else return @alias.fetch("error", @validator.get_errors) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ruby-livr-2.0.0 | lib/livr/aliased_rule.rb |
livr2-2.0.0 | lib/livr/aliased_rule.rb |