Releases: dry-rb/dry-validation
Releases · dry-rb/dry-validation
v1.1.1
v1.1.0
Added
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)valuesupports hash-based path specifications now (refs #547) (@solnic)valuecan read multiple values when the key points to them, ie in case ofrule(geo: [:lat, :lon])it would return an array withlatandlon(@solnic)
Fixed
- Passing multiple macro names to
validateoreachworks correctly (fixed #538 #541) (@jandudulski)
v1.0.0
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.
✨ Release highlights ✨
- New
Dry::Validation::ContractAPI for defining contract classes with schemas and validation rules - Improved message backends with support for
keyandbasemessages, and arbitrary meta-data (like error codes etc.) - Support for defining rules for array elements ie
rule(:items).each { ... } - Support for macros that encapsulate common rule logic
- Built-in
:acceptancemacro
v0.13.2
Fixed
- Caching message templates uses restricted set of known keys to calculate cache keys (solnic)
v1.0.0.rc3
Added
- [EXPERIMENTAL]
Validation.register_macrofor registering global macros (solnic) - [EXPERIMENTAL]
Contract.register_macrofor registering macros available to specific contract classes (solnic) Dry::Validation.Contractshortcut for quickly defining a contract and getting its instance back (solnic)- New configuration option
config.localefor setting the default locale (solnic)
Fixed
config/errors.ymlare now bundled with the gem,rc2was broken because of this (solnic)
v1.0.0.rc2 (YANKED)
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.
Added
- [EXPERIMENTAL] support for registering macros via
Dry::Validation::Macros.register(:your_macro, &block)(solnic) - [EXPERIMENTAL]
:acceptanceas the first built-in macro (issue #157) (solnic)
Fixed
- Passing invalid argument to
failurewill raise a meaningful error instead of crashing (solnic)
Changed
- In rule validation blocks,
valuesis now an instance of a hash-likeDry::Validation::Valuesclass, rather thanDry::Schema::Result. This gives more convenient access to data within rules (solnic) - Dependency on
dry-schemawas updated to~> 1.0(solnic)
v1.0.0.rc1
Added
:hintsextension is back (solnic)Resultobjects have access to the context object which is shared between rules (flash-gordon)
Fixed
- Multiple hint messages no longer crash message set (flash-gordon)
Contract#inspectno longer crashes (solnic)
Changed
- Dependency on
dry-schemawas bumped to~> 0.6- this pulls indry-types 1.0.0anddry-logic 1.0.0(solnic) - Dependency on
dry-initializerwas bumped to~> 3.0(solnic)
v1.0.0.beta2
Added
-
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)
Changed
- [BREAKING]
Errorwas renamed toMessageas it is a more generic concept (solnic) - [BREAKING]
ErrorSetwas renamed toMessageSetfor consistency (solnic) - [BREAKING]
:monadsextension wraps entire result objects inSuccessorFailure(flash-gordon)
v1.0.0.beta1
Added
- New API for setting failures
base.failurefor base errors andkey.failurefor key errors (solnic) - Support for
baseerrors associated with a key even when child keys have errors too (solnic) - Support for
baseerrors not associated with any key (solnic) - Result objects use
ErrorSetobject now for managing messages (solnic) - Nested keys are properly handled when generating messages hash (issue #489) (flash-gordon + solnic)
- Result objects support
localeandfulloptions now (solnic) - Ability to configure
top_namespacefor messages, which will be used for both schema and rule localization (solnic) - Rule blocks receive a context object that you can use to share data between rules (solnic)
Changed
- [BREAKING]
Result#errorsreturns an instance ofErrorSetnow, it's an enumerable, coerible to a hash (solnic) - [BREAKING]
failurewas removed in favor ofkey.failureorkey(:foo).failure(solnic) - [BREAKING]
Result#to_hashwas removed (flash-gordon)
v0.13.1
v0.13.1 2019-03-22
Changed
dry-typeswas locked to~> 0.14.0(flash-gordon)