Validation library with type-safe schemas and rules
MIT License
Bot releases are hidden (Show)
Published by solnic almost 4 years ago
rule_error?
predicate (issue #658 closed via #673) (@moofkit)Contract#call
(issue #674 via #675) (@pyromaniac)key?
within a rule no longer crashes when value is nil
or an empty string (issue #670 fixed via #672) (@alexxty7)key?
helper (see #664 for more info) (@alassek)rule(:foo).each do |index:|
(issue #606 done via #657) (@mrbongiolo).each(:foo)
works as expected when there are errors related to other keys (issue #659 fixed via #660) (@solnic)Result#error?
is now a public API and it takes into consideration both schema and rule errors (issue #655 fixed via #656) (@PragTob)key?
predicate in rules no longer crashes when the rule path points to a non-existent array value (issue #653 fixed via #654) (@solnic):hints
extension (@schokomarie)full: true
option works as expected with custom rule messages (issue #618 fixed via #651) (@sirfilip)locale: ...
option works as expected with hints (issue #589 fixed via #652) (@sirfilip)schema_error?
rule helper (@waiting-for-dev)rule_error?
rule helper (@waiting-for-dev)~> 1.5
(@solnic)KeyMap
patches have been removed since dry-schema now provides required functionality (@solnic)MessageSet
would be marked as empty too early (@ianwhite)Contract.ensure_valid_keys
(@grzegorz-jakubiak)values
within rules uses Hash#fetch_values
internally now, which improves performance (@esparta)Rule#each
would crash when the value is not an array (issue #567) (@solnic):predicates_as_macros
(@waiting-for-dev)dry-schema
dependency was bumped to >= 1.3.1
(@solnic)key?
method available within rules, that can be used to check if there's a value under the rule's default key (refs #540) (@solnic)value
supports hash-based path specifications now (refs #547) (@solnic)value
can read multiple values when the key points to them, ie in case of rule(geo: [:lat, :lon])
it would return an array with lat
and lon
(@solnic)validate
or each
works correctly (fixed #538 #541) (@jandudulski)This release is a complete rewrite on top of dry-schema
that uses contract classes to define schema and validation rules. It's not backward-compatible. This release addressed over 150 known issues, including bugs and missing features.
See the list of all addressed issues as well as issues that were moved to dry-schema and addressed there.
Dry::Validation::Contract
API for defining contract classes with schemas and validation ruleskey
and base
messages, and arbitrary meta-data (like error codes etc.)rule(:items).each { ... }
:acceptance
macroValidation.register_macro
for registering global macros (solnic)Contract.register_macro
for registering macros available to specific contract classes (solnic)Dry::Validation.Contract
shortcut for quickly defining a contract and getting its instance back (solnic)config.locale
for setting the default locale (solnic)config/errors.yml
are now bundled with the gem, rc2
was broken because of this (solnic)Published by solnic over 5 years ago
This was yanked on rubygems.org because the bundled gem was missing config
directory, thus it was not possible to require it. It was fixed in rc3
.
Dry::Validation::Macros.register(:your_macro, &block)
(solnic):acceptance
as the first built-in macro (issue #157) (solnic)failure
will raise a meaningful error instead of crashing (solnic)values
is now an instance of a hash-like Dry::Validation::Values
class, rather than Dry::Schema::Result
. This gives more convenient access to data within rules (solnic)dry-schema
was updated to ~> 1.0
(solnic):hints
extension is back (solnic)Result
objects have access to the context object which is shared between rules (flash-gordon)Contract#inspect
no longer crashes (solnic)dry-schema
was bumped to ~> 0.6
- this pulls in dry-types 1.0.0
and dry-logic 1.0.0
(solnic)dry-initializer
was bumped to ~> 3.0
(solnic)