Sha256: 1119a428fada871230c76b44586314b1dcc90466bd8c4a7cb180bbbc5368c9d5
Contents?: true
Size: 761 Bytes
Versions: 3
Compression:
Stored size: 761 Bytes
Contents
# frozen_string_literal: true # Validatior class for form # # @attr_reader [Dry::Validation::Schema] schema Schema for validation # @attr_reader [Hash] errors Array with errors class Ciesta::Validator attr_reader :errors # Constructor def initialize @errors = [] end # Set schema for validation # # @api private # @param [Block] block Block wich returns the schema def use(&block) @schema = Dry::Validation.Params(&block) end # Checks if schema is valid # # @param [Hash<Symbol, any>] attributes Attributes to check # # @api private # @return [Boolean] def valid?(attributes) return true if schema.nil? @errors = schema.call(attributes).errors errors.empty? end private attr_reader :schema end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ciesta-0.4.1 | lib/ciesta/validator.rb |
ciesta-0.4.0 | lib/ciesta/validator.rb |
ciesta-0.3.2 | lib/ciesta/validator.rb |