Releases: dry-rb/dry-schema
Releases · dry-rb/dry-schema
v1.5.3
Fixed
- Key validator works correctly with an array with maybe hash as its member (issue #308 fixed via #309) (@tadeusz-niemiec)
Changed
v1.5.2
Fixed
Result#{success?,failure?}
work as expected when there are only key validation failures (issue #297 fixed via #298) (@adamransom)
Changed
- 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)
v1.5.1
Fixed
- 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)
v1.5.0
Added
- 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)
Fixed
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)
Changed
: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)
v1.4.3
Added
- 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
Fixed
- Some keyword warnings that slipped into the previous release (@flash-gordon)
v1.4.2
Fixed
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)
v1.4.1
v1.4.0
Added
-
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
Fixed
- Added/fixed support for custom optional types (@flash-gordon)
v1.3.4
v1.3.3
Fixed
- 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)