- Default error message for
:uri?
(issue #476 via #477) (@timjnh)
- Fix json-schema type of objects nested under arrays (issue #400 fixed via #462) (@tomgi)
- i18n backend is no longer eager-loaded (via 85a9e0b) (@adam12)
- Fix struct extension for nested struct definitions (via #466) (@flash-gordon)
- Fix custom predicates setting (via #460) (@solnic)
- Support sum types of hashes (issue #446 fixed via #457) (@segiddins)
- Change required metadata back to true to fix regressions (issue #438 fixed via 439) (@robhanlon22)
- Compatibility with dry-configurable 1.0.1 (@flash-gordon)
- Warnings about using pattern matching on Ruby 2.7 (issue #441 fixed via #442) (@r7kamura)
- Make message cache fully thread-safe (via #440) (@mensfeld)
- This version depends on dry-core 1.0 and dry-configurable 1.0 (@flash-gordon)
- Fixed
array(sum_type)
syntax which was a regression introduced in 1.10.0 (issue #436 fixed via #437) (@solnic)
- Setting up message backends with custom settings should work as before (see dry-rb/dry-validation#717 fixed via #435) (@solnic)
- Depend on dry-configurable >= 0.16 - this was needed to play nice with Zeitwerk (@solnic)
- Use zeitwerk for auto-loading which speeds up requires (via #427) (@flash-gordon + @solnic)
- Fix issues with rule name when top_namespace and namespace passed (issue #304 fixed via #432) (@RudskikhIvan)
- Key maps no longer include duped keys when using inheritance (issues #428 #372 fixed via #429) (@solnic)
- Key validator and coercer no longer include duped keys when using parent schemas (via #430) (@solnic)
- Once again reverting zeitwerk related changes that were included in 1.10.3 by an accident :( (@solnic)
- Addressed regressions causing issues with handling sum types (see #419 and #423 fixed via #425) (@robhanlon22)
- Fix value coercion for composed schemas (via #421) (@robhanlon22)
- Reverted zeitwerk-related changes that were included in 1.10.0 by an accident (@solnic)
- Allow nested
filled
andvalue
macro usage (via #412) (@robhanlon22) - Support for more complex scenarios when composing schemas (via #420) (@robhanlon22)
- Fix
or
messages for complex schemas (via #413) (@robhanlon22) - Using
filled
with a constrained constructor type works as expected (via #416) (@robhanlon22) - Fix types and key maps for composed schemas (via #415) (@robhanlon22)
- Freeze message hash (fixes #417 via #418) (@solnic)
- Support
anyOf
composition in JSON schema output (@robhanlon22)
- Allow composition of multiple ors (issue #307 fixed via #409) (@robhanlon22)
- Fix loose JSON schemas for nested hashes (via #401) (@tomdalling)
- Correct spelling error 'mininum' to 'minimum' in json-schema extension (via #404) (@svenanderzen)
- [performance] YAML message backend allocates less strings (via #399) (@casperisfine)
- Namespaced messages no longer crashes in certain scenarios (see dry-rb/dry-validation#692 fixed via #398) (@krekoten)
- [EXPERIMENTAL]
json_schema
extension which allows you to convert a schema into a JSON schema (via #369) (@ianks)
- Composing schemas no longer crashes in certain scenarios (issue #342 fixed via #366) (@vsuhachev)
- Fix info extension for typed arrays (issue #394 fixed via #397) (@CandyFet)
- [internal] Upgraded to new
setting
API provided in dry-configurable 0.13.0 (@timriley in #356)
- [internal] Use explicit
#to_h
conversion of Dry::Configurable::Config, to ensure compatibility with upcoming dry-configurable 0.13.0 release (via #371) (@timriley)
This release ships with a bunch of internal refactorings that should improve performance but if you see any unexpected behavior please do report issues.
- Handle arrays of hashes where Array constructor coerces non-Hash input (#351 fixed via #354) (@ojab)
- Run outer schema processor steps before inner ones (issue #350 fixed via #361) (@ojab)
- Fix key validator false negatives on empty collections (see #363) (@Drenmi)
- Prevent error message YAML files from being parsed multiple times (issue #352 via #364) (@alassek)
- Using constructor types should work fine now ie
required(:foo).filled(Types::Params::Integer.constructor(&:succ))
(issue #280 fixed via #365) (@solnic) - Handle non-Hash to Hash transformation in
before(:key_coercer)
(issue #350 fixed via #362) (@ojab)
- [internal]
Dry::Schema::Path
clean up and performance improvements (via #358) (@ojab) - [internal] simplify and speed up handling of steps in nested schemas (via #360) (@ojab)
- A default error message for
respond_to?
predicate (@rindek)
- Using
respond_to?
predicate in blocks works now (@rindek)
- Messages#[] handles meta/no meta cases more gracefully and has better interoperability with the I18n backend. This brings MessageCompiler#visit_unexpected_key up to parity with MessageCompiler#visit_predicate. Uses visit_predicate as basis for visit_unexpected_key. (@robhanlon22)
- Using sum types with a i18n backend no longer crashes (issue #328 fixes via #331) (@tylerhunt)
-
Inferring predicates from class names is deprecated. It's very unlikely your code depends on it, however, if it does, you'll get an exception with instructions. (@flash-gordon)
If you see an exception and don't rely on inferring, just disable it with:
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name false
Otherwise, enable it explicitly:
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name true
See #335 for rationale.
- Fixed stack error which was a regression introduced in 1.5.5 (issue #322 fixed via #323) (@flash-gordon)
- Key validation works with messages that have meta-data (issue #310 fixed via #313) (@tadeusz-niemiec)
- Using an external schema along with a key specified as a
:hash
works as expected (issue #296 fixed via #315) (@tadeusz-niemiec + @solnic) Result#error?(path)
works correctly when the path points to an array item (issue #317 fixed via #318) (@solnic)
2020-09-03
- Key validation works correctly with a non-nested maybe hashes (issue #311 fixed via #312) (@svobom57)
- Key validator works correctly with an array with maybe hash as its member (issue #308 fixed via #309) (@tadeusz-niemiec)
- [info extension] small performance improvement in the set visitor (see #305 for more details) (@esparta)
Result#{success?,failure?}
work as expected when there are only key validation failures (issue #297 fixed via #298) (@adamransom)
- Using
full
option no longer adds a space between the name of a key and the message in case of languages that have no spaces between words (ie Japanese) (issue #161 closed via #292 by @tadeusz-niemiec)
- Negated predicates support the logic operator API now (fixed via #276 by @solnic)
- Fixed circular require warning (issue #279 closed via #282 by @landongrindheim)
- Validating keys against an array with non-hash members no longer crashes (issue #283 fixed via #284 by @beechnut and issue #289 fixed via #288 by @tadeusz-niemiec)
- Support for complex sum types ie
value([:integer, array[:integer])
(issue #214) (@solnic) - You can now set global config via
Dry::Schema.config
(issue #205) (@robhanlon22) - Default error message for
:uuid_v4?
predicate (isssue #230) (@solnic) - [experimental] you can compose schemas in the DSL using the standard logic operators (issue #231 closed via #245) (@solnic)
- Hash schema type can now be used with proper keys and predicates inferring. Constructor
and default types are explicitly not supported (@flash-gordon)
UserType = Dry::Types['hash'].schema( name: 'string', email: 'string' ) Dry::Schema.define do require(:user).hash(UserType) end
:struct
extension which allows using dry-struct classes as source for hash schemas. Note that output will still be presented as plain hashes, returning structs from schemas will require more work, it's planned for next versions (@flash-gordon):info
extension which adds #info method to your schemas which produces a simple hash providing information about keys and types (issue #36 closed via #262) (@solnic)
maybe
macro in JSON schemas no longer converts empty strings tonil
. This was a bug in dry-types but your code may rely on this behavior. If you still require this behavior, we recommend using a custom type (see Advanced -> Custom types in the docs) (@flash-gordon)- YAML message backend no longer crashes when load_paths are empty (@robhanlon22)
- Callbacks can now be inherited from multiple parents (@skryukov)
- Callbacks work with nested schemas (issue #209) (@solnic)
- Custom type is respected when defining nested schemas (issue #174 closed via 263) (@solnic)
- Key map is properly inferred for maybe-hashes (issue #266 fixed via #269) (@solnic)
:i18n
message backend delegates interpolation and caching toI18n
(issue #211) (@robhanlon22)- Raise ArgumentError in DSL if parent DSL configs differ (@robhanlon22)
- (internal)
PredicateInferrer
was removed.Dry::Types::PredicateInferrer
is a drop-in replacement (@flash-gordon)
- Pattern matching for
Dry::Schema::Result
objects (@flash-gordon)Try it with monads!schema = Dry::Schema::Params { required(:name).filled } case schema.('name' => 'John') in name: name # => 'John' end
- Shortcut for nested schemas in
value
andmaybe
macros (@waiting-for-dev)Dry::Schema.Params do required(:address).value(:hash) do required(:city).filled end end
- Some keyword warnings that slipped into the previous release (@flash-gordon)
I18n
messages backend supports procs as text properly (issue #208) (@robhanlon22)I18n
messages backend supports message meta-data (issue #210) (@robhanlon22)- Fixed keyword warnings from MRI 2.7.0 (@flash-gordon)
- Array with a member works correctly with
maybe
(issue #206) (@solnic)
- Child schemas no longer mutate processing steps of their parent classes (@skryukov)
-
Support for passing multiple parent schemas. They are inherited from left to right (@ianwhite)
Dry::Schema.define(parent: [parent_a, parent_b, parent_c]) do ... end
-
Improved error messages about missing translations (@skryukov)
-
[experimental] before/after callbacks for schema steps (@skryukov)
Dry::Schema.Params do required(:name).value(:string) optional(:age).value(:integer) before(:value_coercer) do |result| result.to_h.compact end end
- Added/fixed support for custom optional types (@flash-gordon)
- Fixed regression where using
array?
predicate within a block would crach (issue #186) (@skryukov)
- Reject attempts to build a nested schema for array types built on
Dry::Types::Nominal
(fixed #171) (@flash-gordon) - Current
I18n.locale
is now properly handled when caching message templates (@flash-gordon) - Default processor uses strict types by default, which fixes various cases when
maybe
is used with a constructor type (@flash-gordon) - Namespaced messages no longer causes a crash when used with nested schemas (fixed #176) (@solnic)
- Support for new predicates:
bytesize?
,min_bytesize?
andmax_bytesize?
(@bmalinconico)
Result#error?
works correctly with nested hashes and arrays (@solnic):hints
extension no longer causes a crash where base messages are generated too (issue #165) (@solnic)
-
Automatic predicate inferring for constrained types! (@flash-gordon)
Types::Name = Types::String.constrained(min_size: 1) schema = Dry::Schema.define do required(:name).value(Types::Name) end schema.(name: '').errors.to_h # => { name: ["size cannot be less than 1"] }
-
Support for redefining re-used schemas (issue #43) (@skryukov)
- Type container is passed down to nested schemas (@flash-gordon)
-
Ability to configure your own type container (@Morozzzko)
types = Dry::Schema::TypeContainer.new types.register( 'params.trimmed_string', Types::String.constructor(&:strip).constructor(&:downcase) ) Dry::Schema.Params do config.types = types require(:name).value(:trimmed_string) end
filled
macro no longer generates incorrect messages for arrays (issue #151) (@solnic)filled
macro works correctly with constructor types (@solnic)filled
works correctly with nested schemas (#149) (@solnic + @timriley)- Custom array constructors are no longer discredited by
array
macro (@solnic) BigDecimal
type is correctly handled by predicate inference (@solnic)- Works with latest
dry-logic
which provides the newrespond_to?
predicate (#153) (@flash-gordon)
- Fixes related to
filled
restored pre-1.1.0 behavior of:hints
which are again included (@solnic) filled
no longer uses filter rules to handle empty strings inParams
(@solnic)
config.messages.default_locale
for setting...default locale (surprise, surprise) (@solnic)Config
exposespredicates
setting too (@solnic)
filled
macro behavior results inmust be filled
error messages when appropriate - see PR #141 for more information (issue #134) (@solnic)- Filter rules no longer cause keys to be added to input (issue #142) (@solnic)
- Filter rules work now with inheritance (@solnic)
- Inherited type schemas used by coercion are now properly configured as
lax
type (@solnic) Config
is now finalized before instantiating schemas and properly dupped when its inherited (@flash-gordon + @solnic)Config#eql?
works as expected (@solnic)- Predicates are properly inferred from array with a member type spec, ie
array[:integer]
results inarray? + each(:integer?)
(issue #140) (@solnic)
Object#hash
is no longer used to calculate cache keys due to a potential risk of having hash collisions (@solnic)- Predicate arguments are used again for template cache keys (@solnic)
I18n
messages backend no longer evaluates templates twice (@solnic)
- Caching message templates uses restricted set of known keys to calculate cache keys (issue #132) (@solnic)
- Applying
key?
predicate no longer causes recursive calls toResult#errors
(issue #130) (@solnic)
- Setting
:any
as the type spec no longer crashes (@solnic) Result#error?
handles paths to array elements correctly (@solnic)
- [BREAKING]
Result#to_hash
was removed (@solnic)
- Dependency on
dry-types
was bumped to~> 1.0
(@solnic) - Dependency on
dry-logic
was bumped to~> 1.0
(@solnic) - Dependency on
dry-initializer
was bumped to~> 3.0
(@solnic)
- Key map no longer crashes on unexpected input (issue #118) (@solnic)
-
Support for arbitrary meta-data in messages, ie:
en: dry_schema: errors: filled?: text: "cannot be blank" code: 123
Now your error hash will include
{ foo: [{ text: 'cannot be blank', code: 123 }] }
(@solnic + @flash-gordon) -
Support for type specs in
array
macro, ierequired(:tags).array(:integer)
(@solnic) -
Support for type specs in
each
macro, ierequired(:tags).each(:integer)
(@solnic) -
Shortcut for defining an array with hash as its member, ie:
Dry::Schema.Params do required(:tags).array(:hash) do required(:name).filled(:string) end end
- Inferring predicates doesn't crash when
Any
type is used (@flash-gordon) - Inferring type specs when type is already set works correctly (@solnic)
- [BREAKING]
:monads
extension wraps entire result objects inSuccess
orFailure
(@flash-gordon) - When
:hints
are disabled, result AST will not include hint nodes (@solnic)
- Schemas are now compatible with procs via
#to_proc
(issue #53) (@solnic) - Support for configuring
top_namespace
for localized messages (@solnic) - Support for configuring more than one load path for localized messages (@solnic)
- Support for inferring predicates from arbitrary types (issue #101) (@solnic)
- Handling of messages for
optional
keys without value rules works correctly (issue #87) (@solnic) - Message structure for
optional
keys with an array of hashes no longer duplicates keys (issue #89) (@solnic) - Inferring
:date_time?
predicate works correctly withDateTime
types (issue #97) (@solnic)
- [BREAKING] Updated to work with
dry-types 0.15.0
(@flash-gordon) - [BREAKING]
Result#{errors,messages,hints}
returnsMessageSet
object now which is an enumerable coercible to a hash (@solnic) - [BREAKING]
Messages
backend classes no longer use global configuration (@solnic) - [BREAKING] Passing a non-symbol key name in the DSL will raise
ArgumentError
(issue #29) (@solnic) - [BREAKING] Configuration for message backends is now nested under
messages
key with following settings:messages.backend
- previouslymessages
messages.load_paths
- previouslymessages_path
messages.namespace
- previouslynamespace
messages.top_namespace
- new setting see above
- [BREAKING]
Messages::I18n
usesI18.store_translations
instead of messing withI18n.load_path
(@solnic) - Schemas (
Params
andJSON
) have nicer inspect (@solnic)
- Configuration is properly inherited from a parent schema (@skryukov)
Result#error?
returnstrue
when a preceding key has errors (@solnic)- Predicate inferrer no longer chokes on sum, constructor and enum types (@solnic)
- Predicate inferrer infers
:bool?
from boolean types (@solnic) - Block-based definitions using
array
works correctly (@solnic) - Using a disjunction with
array
andhash
produces correct errors when element validation for array failed (@solnic)
- Required ruby version was removed from gemspec for people who are stuck on MRI 2.3.x (@solnic)
- New
hash
macro which prependshash?
type-check and allows nested schema definition (@solnic) - New
array
macro which works likeeach
but prependsarray?
type-check (@solnic)
- Rule name translation works correctly with I18n (issue #52) (@solnic)
- Rule name translation works correctly with namespaced messages (both I18n and plain YAML) (issue #57) (@solnic)
- Error messages under namespaces are correctly resolved for overridden names (issue #53) (@solnic)
- Namespaced error messages work correctly when schemas are reused within other schemas (issue #49) (@solnic)
- Child schema can override inherited rules now (issue #66) (@skryukov)
- Hints are correctly generated for disjunction that use type-check predicates (issue #24) (@solnic)
- Hints are correctly generated for nested schemas (issue #26) (@solnic)
filled
macro respects inferred type-check predicates and puts them in front (@solnic)- Value coercion works correctly with re-usable nested schemas (issue #25) (@solnic)
- [BREAKING] Messages are now configured under
dry_schema
namespace by default (issue #38) (@solnic) - [BREAKING] Hints are now an optional feature provided by
:hints
extension, to load it doDry::Schema.load_extensions(:hints)
(@solnic) - [BREAKING] Hints generation was improved in general, output of
Result#messages
andResult#hints
changed in some cases (@solnic) - [BREAKING]
schema
macro no longer prependshash?
check, for this behavior use the newhash
macro (see #31) (@solnic) - [BREAKING] Support for MRI < 2.4 was dropped (@solnic)
Result#error?
supports checking nested errors too ieresult.error?('user.address')
(@solnic)
- Fix issues with templates and invalid tokens (issue #27) (@solnic)
- Fix Ruby warnings (@flash-gordon)
Initial release.