[FEATURE] Update cuyz/valinor to v2 #489
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^1.4
->^2.0
Release Notes
CuyZ/Valinor (cuyz/valinor)
v2.0.0
Compare Source
First release of the v2 series! 🎉
This release introduces some new features but also backward compatibility breaks that are detailed in the upgrading chapter: it is strongly recommended to read it carefully before upgrading.
Notable new features
Mapper converters introduction
A mapper converter allows users to hook into the mapping process and apply custom logic to the input, by defining a callable signature that properly describes when it should be called:
These two types are enough for the library to know when to call the converter and can contain advanced type annotations for more specific use cases.
Below is a basic example of a converter that converts string inputs to uppercase:
Converters can be chained, allowing multiple transformations to be applied to a value. A second
callable
parameter can be declared, allowing the current converter to call the next one in the chain.A priority can be given to a converter to control the order in which converters are applied. The higher the priority, the earlier the converter will be executed. The default priority is 0.
More information can be found in the mapper converter chapter.
NormalizerBuilder
introductionThe
NormalizerBuilder
class has been introduced and will now be the main entry to instantiate normalizers. Therefore, the methods inMapperBuilder
that used to configure and return normalizers have been removed.This decision aims to make a clear distinction between the mapper and the normalizer configuration API, where confusion could arise when using both.
The
NormalizerBuilder
can be used like this:Changes to messages/errors handling
Some changes have been made to the way messages and errors are handled.
It is now easier to fetch messages when error(s) occur during mapping:
Upgrading from 1.x to 2.x
See the upgrading chapter.
⚠ BREAKING CHANGES
MapperBuilder
andNormalizerBuilder
(123058)MappingError
(378141)NormalizerBuilder
as the main entry for normalizers (f79ce2)@internal
(7fe5fe)MapperBuilder::alter()
in favor of mapper converters (bee098)MapperBuilder::enableFlexibleCasting()
(f8f16d)PrioritizedList
(0b8c89)IdentifiableSource
(aefb20)MapperBuilder::warmup()
method towarmupCacheFor()
(963156)Features
MapperBuilder
andNormalizerBuilder
to clear cache (fe318c)Bug Fixes
Other
Throwable
inheritance fromErrorMessage
(dbd731)v1.17.0
Compare Source
Notable changes
Flexible casting setting split
The mapper setting
enableFlexibleCasting
is (softly) deprecated in favor of three distinct modes, which guarantee the same functionalities as before.Allowing scalar value casting:
With this setting enabled, scalar types will accept castable values:
Integer types will accept any valid numeric value, for instance the string value
"42"
.Float types will accept any valid numeric value, for instance the string value
"1337.42"
.String types will accept any integer, float or object implementing the
Stringable
interface.Boolean types will accept any truthy or falsy value:
(string) "true"
,(string) "1"
and(int) 1
will be cast totrue
(string) "false"
,(string) "0"
and(int) 0
will be cast tofalse
Allowing non-sequential lists:
By default, list types will only accept sequential keys starting from 0.
This setting allows the mapper to convert associative arrays to a list with sequential keys.
Allowing undefined values:
Allows the mapper to accept undefined values (missing from the input), by converting them to
null
(if the current type is nullable) or an empty array (if the current type is an object or an iterable).Features
Other
ValueNode
implementation (7e6ccf)Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.