Validation library with type-safe schemas and rules
MIT License
Bot releases are hidden (Show)
Published by solnic over 5 years ago
Support for arbitrary meta-data in failures, ie:
class NewUserContract < Dry::Validation::Contract
params do
required(:login).filled(:string)
end
rule(:login) do
key.failure(text: 'is taken', code: 123) unless db.unique?(values[:login])
end
end
Now your error hash will include { login: [{ text: 'is taken', code: 123 }] }
(solnic + flash-gordon)
Error
was renamed to Message
as it is a more generic concept (solnic)ErrorSet
was renamed to MessageSet
for consistency (solnic):monads
extension wraps entire result objects in Success
or Failure
(flash-gordon)Published by solnic over 5 years ago
base.failure
for base errors and key.failure
for key errors (solnic)base
errors associated with a key even when child keys have errors too (solnic)base
errors not associated with any key (solnic)ErrorSet
object now for managing messages (solnic)locale
and full
options now (solnic)top_namespace
for messages, which will be used for both schema and rule localization (solnic)Result#errors
returns an instance of ErrorSet
now, it's an enumerable, coerible to a hash (solnic)failure
was removed in favor of key.failure
or key(:foo).failure
(solnic)Result#to_hash
was removed (flash-gordon)dry-types
was locked to ~> 0.14.0
(flash-gordon)The first round of bug fixes. Thanks for testing <3!
errors.rule.%{key}
too, but a message under nested key will override it (solnic)Complete rewrite on top of dry-schema
.
Dry::Validation::Contract
as a replacement for validation schemas (solnic)rule
DSL with an improved API for setting error messages (solnic)~> 0.4.2
(flash-gordon)dry-types
0.13.1 and dry-struct
0.5.0, these are now minimal supported versions (flash-gordon)Form
was renamed to Params
to be consistent with the latest changes from dry-types
. You can require 'dry/validation/compat/form'
to use the previous names but it will be removed in the next version (flash-gordon)Published by solnic over 7 years ago