Since the rule "GreaterThan" was created, there is no reason to allow
"Min" to not be inclusive.
Also apply contribution guidelines to the rule.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This changes the rule name in order to be more descriptive and explicit
(avoid abbreviation). It also applies the new contribution guidelines.
Signed-off-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
Since the rule "LessThan" was created, there is no reason to allow "Max"
to not be inclusive.
Also apply contribution guidelines to the rule.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Generally speaking it makes more sense to have it always inclusive. Even
though the word "between" does not imply that it is inclusive or
exclusive it's more natural this way.
Besides, users can always use "GreaterThan" and "LessThan" rules in case
that is necessary.
Removing this boolean parameter reduces a bit of the complexity of the
rule.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Also add an extra validation to the rule, not allowing non-integers to
be considered as even numbers.
Co-Authored-By: Henrique Moody <henriquemoody@gmail.com>
This method change the behavior of "getMessages()" by changin the keys
of its return to the "id" of the specific exception that was triggered.
It also allows users to overwrite the templates by passing an array to
it.
This is being requested by many users for a long time. It took that long
because I was thinking too much about how to improve the old method
called "findMesssage()" that I didn't realize that it could be done in a
easier way with the "getMessages()".
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Make the ValidationException a little bit less mutable than before. All
its dependencies are now passed into the constructor.
This commit also make the Factory pass the translator to the exceptions
allowing to define the translator before the exception gets created.
This change is not the ideal one, later I would like to not need the
Singleton from the Factory to do that, but for now it seems like a good
approach.
One more thing that this commit does is to introduce the "id" for
Exceptions. Key can be either the defined "name" or the name of the rule
that throwed the exception. This method will be handy to identify
exceptions better.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The "MinimumAge" exception should use the "{{ name }}" placeholder
instead of the "{{ input }}" once that one can be either the input or a
user-defined name.
In the default message, the placeholder was using sprintf format, but
the correct way is to use "{{name}}". Also use the same style of the
other messages in the default message.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>