dry-schema/changelog.yml

619 lines
23 KiB
YAML

---
- version: 1.12.0
date: 2022-11-04
changed:
- 'This version depends on dry-core 1.0 and dry-configurable 1.0 (@flash-gordon)'
- version: 1.11.3
summary:
date: 2022-10-21
fixed:
- 'Fixed `array(sum_type)` syntax which was a regression introduced in 1.10.0 (issue
#436 fixed via #437) (@solnic)'
added:
changed:
- version: 1.11.2
summary:
date: 2022-10-16
fixed:
- 'Setting up message backends with custom settings should work as before (see dry-rb/dry-validation#717
fixed via #435) (@solnic)'
added:
changed:
- version: 1.11.1
date: 2022-10-15
changed:
- Depend on dry-configurable >= 0.16 - this was needed to play nice with Zeitwerk
(@solnic)
- version: 1.11.0
summary:
date: 2022-10-15
fixed:
added:
changed:
- 'Use zeitwerk for auto-loading which speeds up requires (via #427) (@flash-gordon
+ @solnic)'
- version: 1.10.6
summary:
date: '2022-10-01'
fixed:
- 'Fix issues with rule name when top_namespace and namespace passed (issue #304
fixed via #432) (@RudskikhIvan)'
added:
changed:
- version: 1.10.5
summary:
date: '2022-09-21'
fixed:
- '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)'
added:
changed:
- version: 1.10.4
summary:
date: '2022-09-13'
fixed:
- Once again reverting zeitwerk related changes that were included in 1.10.3 by
an accident :( (@solnic)
added:
changed:
- version: 1.10.3
summary:
date: '2022-09-10'
fixed:
- 'Addressed regressions causing issues with handling sum types (see #419 and #423
fixed via #425) (@robhanlon22)'
added:
changed:
- version: 1.10.2
summary:
date: '2022-08-23'
fixed:
- 'Fix value coercion for composed schemas (via #421) (@robhanlon22)'
added:
changed:
- version: 1.10.1
date: '2022-08-22'
changed:
- Reverted zeitwerk-related changes that were included in 1.10.0 by an accident
(@solnic)
- version: 1.10.0
summary:
date: '2022-08-16'
fixed:
- '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)'
added:
- 'Allow nested `filled` and `value` macro usage (via #412) (@robhanlon22)'
- 'Support for more complex scenarios when composing schemas (via #420) (@robhanlon22)'
changed:
- 'Freeze message hash (fixes #417 via #418) (@solnic)'
- version: 1.9.3
summary:
date: '2022-06-23'
fixed:
- 'Allow composition of multiple ors (issue #307 fixed via #409) (@robhanlon22)'
added:
- Support `anyOf` composition in JSON schema output (@robhanlon22)
changed:
- version: 1.9.2
summary:
date: '2022-05-28'
fixed:
- 'Fix loose JSON schemas for nested hashes (via #401) (@tomdalling)'
- 'Correct spelling error ''mininum'' to ''minimum'' in json-schema extension (via
#404) (@svenanderzen)'
added:
changed:
- "[performance] YAML message backend allocates less strings (via #399) (@casperisfine)"
- version: 1.9.1
summary:
date: '2022-02-17'
fixed:
- 'Namespaced messages no longer crashes in certain scenarios (see dry-rb/dry-validation#692
fixed via #398) (@krekoten)'
added:
changed:
- version: 1.9.0
summary:
date: '2022-02-15'
fixed:
- '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)'
added:
- "[EXPERIMENTAL] `json_schema` extension which allows you to convert a schema into
a JSON schema (via #369) (@ianks)"
changed:
- version: 1.8.0
date: '2021-09-12'
changed:
- "[internal] Upgraded to new `setting` API provided in dry-configurable 0.13.0
(@timriley in #356)"
- version: 1.7.1
date: '2021-08-29'
changed:
- "[internal] Use explicit `#to_h` conversion of Dry::Configurable::Config, to ensure
compatibility with upcoming dry-configurable 0.13.0 release (via #371) (@timriley)"
- version: 1.7.0
summary: This release ships with a bunch of internal refactorings that should improve
performance but if you see any unexpected behavior please do report issues.
date: '2021-06-29'
fixed:
- '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)'
added:
changed:
- "[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)"
- version: 1.6.2
summary:
date: '2021-04-15'
fixed:
- Using `respond_to?` predicate in blocks works now (@rindek)
added:
- A default error message for `respond_to?` predicate (@rindek)
changed:
- version: 1.6.1
summary:
date: 2021-02-02
fixed:
- 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)
added:
changed:
- version: 1.6.0
date: '2021-01-21'
fixed:
- 'Using sum types with a i18n backend no longer crashes (issue #328 fixes via #331)
(@tylerhunt)'
changed:
- |-
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:
```ruby
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name false
```
Otherwise, enable it explicitly:
```ruby
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name true
```
See https://github.com/dry-rb/dry-schema/issues/335 for rationale.
- version: 1.5.6
summary:
date: '2020-10-21'
fixed:
- 'Fixed stack error which was a regression introduced in 1.5.5 (issue #322 fixed
via #323) (@flash-gordon)'
added:
changed:
- version: 1.5.5
summary:
date: '2020-10-08'
fixed:
- '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)"
added:
changed:
- version: 1.5.4
summary: '2020-09-03'
date:
fixed:
- 'Key validation works correctly with a non-nested maybe hashes (issue #311 fixed
via #312) (@svobom57)'
added:
changed:
- version: 1.5.3
summary:
date: '2020-08-21'
fixed:
- 'Key validator works correctly with an array with maybe hash as its member (issue
#308 fixed via #309) (@tadeusz-niemiec)'
added:
changed:
- "[info extension] small performance improvement in the set visitor (see #305 for
more details) (@esparta)"
- version: 1.5.2
summary:
date: '2020-06-26'
fixed:
- "`Result#{success?,failure?}` work as expected when there are only key validation
failures (issue #297 fixed via #298) (@adamransom)"
added:
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)'
- version: 1.5.1
summary:
date: '2020-05-21'
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)'
added:
changed:
- version: 1.5.0
summary:
date: '2020-03-11'
fixed:
- |-
`maybe` macro in JSON schemas no longer converts empty strings to `nil`.
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)'
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)
```ruby
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)"
changed:
- "`:i18n` message backend delegates interpolation and caching to `I18n` (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)"
- version: 1.4.3
date: '2020-01-08'
added:
- |-
Pattern matching for `Dry::Schema::Result` objects (@flash-gordon)
```ruby
schema = Dry::Schema::Params { required(:name).filled }
case schema.('name' => 'John')
in name:
name # => 'John'
end
```
Try it with monads!
- |-
Shortcut for nested schemas in `value` and `maybe` macros (@waiting-for-dev)
```ruby
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)
- version: 1.4.2
date: '2019-12-19'
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)'
- version: 1.4.1
date: '2019-10-08'
fixed:
- Child schemas no longer mutate processing steps of their parent classes (@skryukov)
- version: 1.4.0
date: '2019-10-08'
added:
- |-
Support for passing multiple parent schemas. They are inherited from left to right (@ianwhite)
```ruby
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)
```ruby
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)
- version: 1.3.4
date: '2019-09-11'
fixed:
- 'Fixed regression where using `array?` predicate within a block would crach (issue
#186) (@skryukov)'
- version: 1.3.3
date: '2019-08-14'
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)'
- version: 1.3.2
date: '2019-08-01'
added:
- 'Support for new predicates: `bytesize?`, `min_bytesize?` and `max_bytesize?`
(@bmalinconico)'
- version: 1.3.1
date: '2019-07-08'
fixed:
- "`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)"
- version: 1.3.0
date: '2019-07-06'
added:
- |-
Automatic predicate inferring for constrained types! (@flash-gordon)
```ruby
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)'
fixed:
- Type container is passed down to nested schemas (@flash-gordon)
- version: 1.2.0
date: '2019-06-13'
added:
- |-
Ability to configure your own type container (@Morozzzko)
```ruby
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
```
fixed:
- "`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 new `respond_to?` predicate (#153)
(@flash-gordon)
changed:
- 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 in `Params` (@solnic)"
- version: 1.1.0
date: '2019-05-30'
added:
- "`config.messages.default_locale` for setting...default locale (surprise, surprise)
(@solnic)"
- "`Config` exposes `predicates` setting too (@solnic)"
fixed:
- "`filled` macro behavior results in `must 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 in `array? + each(:integer?)` (issue #140) (@solnic)'
- version: 1.0.3
date: '2019-05-21'
fixed:
- "`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)"
- version: 1.0.2
date: '2019-05-12'
fixed:
- 'Caching message templates uses restricted set of known keys to calculate cache
keys (issue #132) (@solnic)'
- version: 1.0.1
date: '2019-05-08'
fixed:
- 'Applying `key?` predicate no longer causes recursive calls to `Result#errors`
(issue #130) (@solnic)'
- version: 1.0.0
date: '2019-05-03'
changed:
- "[BREAKING] `Result#to_hash` was removed (@solnic)"
fixed:
- Setting `:any` as the type spec no longer crashes (@solnic)
- "`Result#error?` handles paths to array elements correctly (@solnic)"
- version: 0.6.0
date: '2019-04-24'
changed:
- 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)
- version: 0.5.1
date: '2019-04-17'
fixed:
- 'Key map no longer crashes on unexpected input (issue #118) (@solnic)'
- version: 0.5.0
date: '2019-04-04'
added:
- |-
Support for arbitrary meta-data in messages, ie:
```yaml
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, ie `required(:tags).array(:integer)`
(@solnic)
- Support for type specs in `each` macro, ie `required(:tags).each(:integer)` (@solnic)
- |-
Shortcut for defining an array with hash as its member, ie:
```ruby
Dry::Schema.Params do
required(:tags).array(:hash) do
required(:name).filled(:string)
end
end
```
fixed:
- Inferring predicates doesn't crash when `Any` type is used (@flash-gordon)
- Inferring type specs when type is already set works correctly (@solnic)
changed:
- "[BREAKING] `:monads` extension wraps entire result objects in `Success` or `Failure`
(@flash-gordon)"
- When `:hints` are disabled, result AST will not include hint nodes (@solnic)
- version: 0.4.0
date: '2019-03-26'
added:
- '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)'
fixed:
- '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 with `DateTime` types (issue
#97) (@solnic)'
changed:
- "[BREAKING] Updated to work with `dry-types 0.15.0` (@flash-gordon)"
- "[BREAKING] `Result#{errors,messages,hints}` returns `MessageSet` 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` - previously `messages`
- `messages.load_paths` - previously `messages_path`
- `messages.namespace` - previously `namespace`
- `messages.top_namespace` - **new setting** see above
- "[BREAKING] `Messages::I18n` uses `I18.store_translations` instead of messing
with `I18n.load_path` (@solnic)"
- Schemas (`Params` and `JSON`) have nicer inspect (@solnic)
- version: 0.3.0
date: '2018-03-04'
fixed:
- Configuration is properly inherited from a parent schema (@skryukov)
- "`Result#error?` returns `true` 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` and `hash` produces correct errors when element
validation for array failed (@solnic)
changed:
- Required ruby version was removed from gemspec for people who are stuck on MRI
2.3.x (@solnic)
- version: 0.2.0
date: '2019-02-26'
added:
- New `hash` macro which prepends `hash?` type-check and allows nested schema definition
(@solnic)
- New `array` macro which works like `each` but prepends `array?` type-check (@solnic)
fixed:
- '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)'
changed:
- "[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 do `Dry::Schema.load_extensions(:hints)` (@solnic)"
- "[BREAKING] Hints generation was improved in general, output of `Result#messages`
and `Result#hints` changed in some cases (@solnic)"
- "[BREAKING] `schema` macro no longer prepends `hash?` check, for this behavior
use the new `hash` macro (see #31) (@solnic)"
- "[BREAKING] Support for MRI < 2.4 was dropped (@solnic)"
- version: 0.1.1
date: '2019-02-17'
added:
- "`Result#error?` supports checking nested errors too ie`result.error?('user.address')`
(@solnic)"
fixed:
- 'Fix issues with templates and invalid tokens (issue #27) (@solnic)'
- Fix Ruby warnings (@flash-gordon)
- version: 0.1.0
date: '2019-01-30'
summary: Initial release.