- Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
format?
predicate is excluded from hints (solnic)
version
file is now required by default (georgemillo)
- Custom predicates work correctly with
each
macro (solnic)
- Constrained types + hints work again (solnic)
- Remove obsolete require of
dry/struct
which is now an optional extension (flash-gordon)
- Support for
validate
DSL which accepts an arbitratry validation block that gets executed in the context of a schema object and is treated as a custom predicate (solnic) - Support for
or
error messages ie "must be a string or must be an integer" (solnic) - Support for retrieving error messages exclusively via
schema.(input).errors
(solnic) - Support for retrieving hint messages exclusively via
schema.(input).hints
(solnic) - Support for opt-in extensions loaded via
Dry::Validation.load_extensions(:my_ext)
(flash-gordon) - Add
:monads
extension which transforms a result instance toEither
monad,schema.(input).to_either
(flash-gordon) - Add
dry-struct
integration via an extension activated byDry::Validation.load_extensions(:struct)
(flash-gordon)
- Input rules (defined via
input
macro) are now lazy-initialized which makes it work with predicates defined on the schema object (solnic) - Hints are properly generated based on argument type in cases like
size?
, where the message should be different for strings (uses "length") or other types (uses "size") (solnic) - Defining nested keys without
schema
blocks results inArgumentError
(solnic)
- [BREAKING]
when
macro no longer supports multiple disconnected rules in its block, whatever the block returns will be used for the implication (solnic) - [BREAKING]
rule(some_name: %i(some keys))
will always use:some_name
as the key for failure messages (solnic)
- ~2 x performance boost (solnic)
- Rule AST was updated to latest dry-logic (solnic)
MessageCompiler
was drastically simplified based on the new result AST from dry-logic (solnic)HintCompiler
is gone as hints are now part of the result AST (solnic)maybe
macro creates an implication instead of a disjunction (not(none?).then(*your-predicates)
) (solnic)
- Infering multiple predicates with options works as expected ie
value(:str?, min_size?: 3, max_size?: 6)
(solnic) - Default
locale
configured inI18n
is now respected by the messages compiler (agustin + cavi21)
- Error messages for sibling deeply nested schemas are nested correctly (timriley)
- Support for range arg in error messages for
excluded_from?
andincluded_in?
(mrbongiolo) Result#message_set
returns raw message set object (solnic)
- Error messages for high-level rules in nested schemas are nested correctly (solnic)
- Dumping error messages works with high-level rules relying on the same value (solnic)
#messages
is no longer memoized (solnic)
- Constrained types now work with
each
macro (solnic) - Array coercion without member type works now ie
required(:arr).maybe(:array?)
(solnic)
I18n
backend is no longer required and set by default (solnic)
- Support for defining maybe-schemas via
maybe { schema { .. } }
(solnic) - Support for interpolation of custom failure messages for custom rules (solnic)
- Support for defining a base schema class with config and rules (solnic)
- Support for more than 1 predicate in
input
macro (solnic) - Class-level
define!
API for defining rules on a class (solnic) :i18n
messages support merging from other paths viamessages_file
setting (solnic)- Support for message token transformations in custom predicates (fran-worley)
- [EXPERIMENTAL] Ability to compose predicates that accept dynamic args provided by the schema (solnic)
- Tokens for
size?
were renamedleft
=>size_left
andright
=>size_right
(fran-worley)
- Duped key names in nested schemas no longer result in invalid error messages structure (solnic)
- Error message structure for deeply nested each/schema rules (solnic)
- Values from
option
are passed down to nested schemas when usingSchema#with
(solnic) - Hints now work with array elements too (solnic)
- Hints for elements are no longer provided for an array when the value is not an array (solnic)
input
macro no longer messes up error messages for nested structures (solnic)
- Compiling messages is now ~5% faster (solnic + splattael)
- Refactored Error and Hint compilers (solnic)
- Refactored Schema to use an internal executor objects with steps (solnic)
- Extracted root-rule into a separate validation step (solnic)
- Added
MessageSet
that result objects now use (in 1.0.0 it'll be exposed via public API) (solnic) - We can now distinguish error messages from validation hints via
Message
andHint
objects (solnic)
- Explicit interface for type specs used to set up coercions, ie
required(:age, :int)
(solnic) - Support new dry-logic predicates:
:excluded_from?
,:excludes?
,:included_in?
,:includes?
,:not_eql?
,:odd?
,:even?
(jodosha, fran-worley) - Support for blocks in
value
,filled
andmaybe
macros (solnic) - Support for passing a schema to
value|filled|maybe
macros iemaybe(SomeSchema)
(solnic) - Support for
each(SomeSchema)
(solnic) - Support for
value|filled|maybe
macros +each
inside a block ie:maybe(:filled?) { each(:int?) }
(solnic) - Support for dedicated hint messages via
en.errors.#{predicate}.(hint|failure)
look-up paths (solnic) - Support for configuring custom DSL extensions via
dsl_extensions
setting on Schema class (solnic) - Support for preconfiguring a predicate for the input value ie
value :hash?
used for prerequisite-checks (solnic) - Infer coercion from constrained types (solnic)
- Add value macro (coop)
- Enable .schema to accept objects that respond to #schema (ttdonovan)
- Support for schema predicates which don't need any arguments (fran-worley)
- Error and hint messages have access to all predicate arguments by default (fran-worley+solnic)
- Invalid predicate name in DSL will raise an error (solnic)
- Predicate with invalid arity in DSL will raise an error (solnic)
- Support for jRuby 9.1.1.0 (flash-gordon)
- Fix bug when using predicates with options in each and when (fran-worley)
- Fix bug when validating custom types (coop)
- Fix depending on deeply nested values in high-lvl rules (solnic)
- Fix duplicated error message for lt? when hint was used (solnic)
- Fix hints for nested schemas (solnic)
- Fix an issue where rules with same names inside nested schemas have incorrect hints (solnic)
- Fix a bug where hints were being generated 4 times (solnic)
- Fix duplicated error messages when message is different than a hint (solnic)
- Uses new
:weak
hash constructor from dry-types 0.8.0 which can partially coerce invalid hash (solnic) key
has been deprecated in favor ofrequired
(coop)required
has been deprecated in favor offilled
(coop)- Now relies on dry-logic v0.3.0 and dry-types v0.8.0 (fran-worley)
- Tring to use illogical predicates with maybe and filled macros now raise InvalidSchemaError (fran-worley)
- Enable coercion on form.true and form.false (fran-worley)
- Remove attr (will be extracted to a separate gem) (coop)
- Deprecate required in favour of filled (coop)
- Deprecate key in favor of required (coop)
- Remove nested key syntax (solnic)
- ~15% performance boost via various optimizations (solnic)
- When using explicit type specs building a schema is ~80-85x faster (solnic)
- No longer uses
Dry::Types::Predicates
as:type?
predicate was moved to dry-logic (solnic) - Integration specs covering predicates with Form and Schema (jodosha)
- Use latest ruby versions on travis (flash-gordon)
- Make pry console optional with IRB as a default (flash-gordon)
- Remove wrapping rules in :set nodes (solnic)
Schema.JSON
with json-specific coercions (coop)- Support for error messages for
odd? and
even?` predicates (fran-worley)
- Depending on deeply nested values in high-level rules works now (solnic)
- Support for inferring rules from constrained type (coop + solnic)
- Support for inferring nested schemas from
Dry::Types::Struct
classes (coop) - Support for
number?
predicate (solnic)
- Creating a nested schema properly sets full path to nested data structure (solnic)
- Error message for
empty?
predicate is now correct (jodosha)
- Switch from
thread_safe
toconcurrent
(joevandyk)
- Support for nested schemas inside high-level rules (solnic)
Schema#to_proc
so that you can dodata.each(&schema)
(solnic)
- You can use
schema
insideeach
macro (solnic)
confirmation
macro defines an optional key with maybe value with_confirmation
suffix (solnic)each
macro works correctly when its inner rule specify just one key (solnic)- error messages for
each
rules where input is equal are now correctly generated (solnic)
- Now depends on
dry-logic
>=0.2.1
(solnic)
- Support for macros:
required
- when value must be filledmaybe
- when value can be nil (or empty, in case ofForm
)when
- for composing high-level rule based on predicates applied to a validated valueconfirmation
- for confirmation validation
- Support for
value(:foo).eql?(value(:bar))
syntax in high-level rules (solnic) - New DSL for defining schema objects
Dry::Validation.Schema do .. end
(solnic) - Ability to define a schema for an array via top-level
each
rule (solnic) - Ability to define nested schemas via
key(:location).schema do .. end
(solnic) - Ability to re-use schemas inside other schemas via
key(:location).schema(LocationSchema)
(solnic) - Ability to inherit rules from another schema via
Dry::Validation.Schema(Other) do .. end
(solnic) - Ability to inject arbitrary dependencies to schemas via
Schema.option
+Schema#with
(solnic) - Ability to provide translations for rule names under
%{locale}.rules.%{name}
pattern (solnic) - Ability to configure input processor, either
:form
or:sanitizer
(solnic) - Ability to pass a constrained dry type when defining keys or attrs, ie
key(:age, Types::Age)
(solnic) Result#messages
supports:full
option to get messages with rule names, disabled by default (solnic)Validation::Result
responds to#[]
and#each
(delegating to its output) and it's an enumerable (solnic)
schema
was removed from the DSL, just usekey(:name).schema
instead (solnic)confirmation
is now a macro that you can call on a key rule (solnic)- rule names for nested structures are now fully qualified, which means you can
provide customized messages for them. ie
user: :email
(solnic) Schema::Result#params
was renamed to#output
(solnic)Schema::Result
is nowValidation::Result
and it no longer has success and failure results, only error results are provided (solnic)
- Qualified rule names properly use last node by default for error messages (solnic)
- Validation hints only include relevant messages (solnic)
:yaml
messages respect:locale
option inResult#messages
(solnic)
- Support for validating objects with attr readers via
attr
(SunnyMagadan) - Support for
value
interface in the DSL for composing high-level rules based on values (solnic) - Support for
rule(name: :something)
syntax for grouping high-level rules under the same name (solnic) - Support for
confirmation(:foo, some_predicate: some_argument)
shortcut syntax (solnic) - Support for error messages for grouped rules (like
confirmation
) (solnic) - Schemas support injecting rules from the outside (solnic)
rule
uses objects that inherit fromBasicObject
to avoid conflicts with predicate names and built-inObject
methods (solnic)- In
Schema::Form
bothkey
andoptional
will applyfilled?
predicate by default when no block is passed (solnic)
- Now depends on dry-logic for predicates and rules (solnic)
dry/validation/schema/form
is now required by default (solnic)
Schema::Form
uses safeform.array
andform.hash
types which fixes #42 (solnic)
- Support for
each
and type coercion inference inSchema::Form
(solnic)
- Support for high-level rule composition via
rule
interface (solnic) - Support for exclusive disjunction (aka xor/^ operator) (solnic)
- Support for nested schemas within a schema class (solnic)
- Support for negating rules via
rule(name).not
(solnic) - Support for
validation hints
that are included in the error messages (solnic)
- Error messages hash has now consistent structure
rule_name => [msgs_array, input_value]
(solnic)
- Support for
Range
andArray
as an argument insize?
predicate (solnic)
- Error compiler returns an empty hash rather than a nil when there are no errors (solnic)
- I18n messages support (solnic)
- Ability to configure
messages
viaconfigure { config.messages = :i18n }
(solnic) rule
interface in DSL for defining rules that depend on other rules (solnic)confirmation
interface as a shortcut for defining "confirmation of" rule (solnic)- Error messages can be now matched by input value type too (solnic)
optional
rule with coercions work correctly with|
+ multiple&
s (solnic)Schema#[]
checks registered predicates first before defaulting to its own predicates (solnic)
Schema#messages(input)
=>Schema#call(input).messages
(solnic)Schema#call
returnsSchema::Result
which has access to all rule results, errors and messagesSchema::Result#messages
returns a hash with rule names, messages and input values (solnic)
Schema::Form
with a built-in coercer inferred from type-check predicates (solnic)- Ability to pass a block to predicate check in the DSL ie
value.hash? { ... }
(solnic) - Optional keys using
optional(:key_name) { ... }
interface in the DSL (solnic) - New predicates:
bool?
date?
date_time?
time?
float?
decimal?
hash?
array?
- Added missing
and
/or
interfaces to composite rules (solnic)
First public release