All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- Support for Ruby 3+ (HolyWalley)
2.1.0 - [2021-11-30]
- Difference between last positional and keyword arguments in Ruby 3.0+ (mrexox)
2.0.1 - [2019-11-14]
- Allow translation :scope to be customized in the #merge operation (sclinede) Before the fix, the customized value was always replaced by the default value.
2.0.0 - [2019-07-04]
-
[BREAKING] separate
Tram::Policy::Errors
from a policy (nepalez, sclinede)Instead of the policy, the collection refers to the explicit scope used for error messages' translation. This change breaks the signature of
Tram::Policy::Error
andTram::Policy::Errors
.
1.0.1 - [2019-05-06]
- Support of
dry-initializer
v3.0+ (nepalez)
- Fix be_invalid RSpec matcher if non-policy model is passed (Envek)
- Disable translation check for non-strings in rspec matcher (Envek)
1.0.0 - [2018-02-17]
-
RSpec matchers does't use blocks any more (nepalez)
Instead of
expect { policy }.to be_invalid_at level: "error"
use the simpler syntax
expect(policy).to be_invalid_at level: "error"
- Deprecated methods (nepalez)
- RSpec shared examples (nepalez)
0.4.0 - [2018-02-17]
This is beta-release before the first stable version 1.0.0.
It adds methods #item
and #items
to policy errors to support lazy translation.
It also renames some methods, and deprecate others that will be removed from v1.0.0.
Tram::Policy.root_scope
changes the default root scope ("tram-policy") for I18n (nepalez)Tram::Policy::Error#item
returns an array of [key, tags] which can be sent to I18n.t later (nepalez)Tram::Policy::Error#to_a
as an alias for the#item
(nepalez)Tram::Policy::Errors#items
returns an array of error items (nepalez)Tram::Policy::Errors#filter
acts likeby_tag
but returns the filtered collection instead of an array (nepalez)Tram::Policy#messages
as a shortcut forerrors.messages
(nepalez)Tram::Policy#items
as a shortcut forerrors.items
(nepalez)
- errors are compared by
#to_a
instead of#to_h
(nepalez)
Tram::Policy::Error#full_message
(nepalez)Tram::Policy::Error#to_h
(nepalez)Tram::Policy::Errors#full_messages
(nepalez)Tram::Policy::Errors#by_tags
(nepalez)
0.3.1 - [2018-01-05]
- Convertion of block into lambda in
validate
(nepalez)
0.3.0 - [2018-01-05]
- Allow returning from block in
validate
by using lambdas (nepalez)
0.2.5 - [2018-01-05]
- Allow
Tram::Policy.scope
to be made private (nepalez)
0.2.4 - [2017-12-03]
Some private methods has been refactored
- Renamed
Tram::Policy@__options__
->Tram::Policy##__attributes__
(nepalez) - Removed
Tram::Policy::Validator##scope
in favor ofTram::Policy.scope
(nepalez) - Refactored spec matcher (nepalez)
0.2.3 - [2017-11-21]
- RSpec matcher
:be_invalid_at
checks all the available locales (nepalez) - Security vulnerability from old version of rubocop (update to 0.49) (nepalez)
0.2.2 - [2017-09-12]
- Policy class methods
all
,local
, andscope
was made public (nepalez)
0.2.1 - [2017-08-28]
- Updated dependency from dry-initializer to v2.0.0 (nepalez)
0.2.0 - [2017-08-19]
-
Support for unnamed block validators (@nepalez)
In addition to instance methods:
validate :some_method
You can use a block for validation:
validate { errors.add :blank_name if name.blank? }
-
Support for custom scopes (@nepalez)
Just reload private class method
scope
-
Support for inheritance (@nepalez)
You can inherit the policy class. A subclass will apply all validators of superclass before those of its own. Every error message will be translated in the scope of policy where it was defined.
-
Reloading of validators
To follow Liskov substitube principle we run all validators declared anywhere in the policy or its superclasses. Any sub-policy should provide the same level of confidence about validity of object(s) under check as any of its superclasses.
0.1.1 - [2017-08-04]
-
Support for options in errors.merge (@nepalez)
errors.merge other_policy.errors, field: "user"
0.1.0 - [2017-05-31]
Contains backward-incompatible change.
You should add the namespace to gem-related I18n translations.
# config/locales/tram-policy.en.yml
---
en:
tram-policy: # The namespace to be added
my_policy:
error_key: Error message
- [BREAKING] a namespace added to scopes for policy error translations (@nepalez)
0.0.3 - [2017-05-24]
- bug in
errors.empty?
with a block (@nepalez with thanks to @gzigzigzeo)
0.0.2 - [2017-04-25]
The gem is battle-tested for production (in a real commertial project).
-
.validate
with several keys for several validators at once (@nepalez)Use a multiline version instead of
validate :foo, :bar
:validate :foo validate :bar
.validate
supports optionstop_on_failure
(@nepalez)
- Minor bugs in generators (@nepalez)
0.0.1 - [2017-04-18]
This is a first public release (@nepalez, @charlie-wasp, @JewelSam, @sergey-chechaev)