| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
| |
Ok, this explains why the branch showed as green. We don't run files in
isolation for PRs, only for master. Active Support monkeypatches
`BigDecimal#to_s`, so the generated error message was different
depending on if the file was run in isolation
|
|
|
|
|
|
|
|
|
| |
The error message when asserting `greater_than: BigDecimal.new` will
give an error message based on how BigDecimal displays itself. Big
decimal appears to always use scientific notation. This might not be the
best error message for the general case, but the general case wouldn't
use big decimal for the validation. And if they do, they likely need
this level of precision.
|
|\
| |
| | |
Use the post-type-cast version of the attribute to validate numericality
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This fixes the issue where you may be comparing (using a numeric
validator such as `greater_than`) numbers of a specific Numeric type
such as `BigDecimal`.
Previous behavior took the numeric value to be validated and
unconditionally converted to Float. For example, due to floating point
precision, this can cause issues when comparing a Float to a BigDecimal.
Consider the following:
```
validates :sub_total, numericality: {
greater_than: BigDecimal('97.18')
}
```
If the `:sub_total` value BigDecimal.new('97.18') was validated against
the above, the following would be valid since `:sub_total` is converted
to a Float regardless of its original type. The result therefore becomes
Kernel.Float(97.18) > BigDecimal.new('97.18')
The above illustrated behavior is corrected with this patch by
conditionally converting the value to validate to float.
Use the post-type-cast version of the attribute to validate numericality
[Roque Pinel & Trevor Wistaff]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Example:
```ruby
class Person
include ActiveModel::Validations
attr_reader :name, :title
validates_presence_of :name, on: :create
validates_presence_of :title, on: :update
end
person = Person.new
person.valid?([:create, :update]) # => true
person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]}
```
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
dmitry/feature/validate-multiple-contexts-at-once"
This reverts commit 51dd2588433457960cca592d5b5dac6e0537feac, reversing
changes made to ecb4e4b21b3222b823fa24d4a0598b1f2f63ecfb.
This broke Active Record tests
|
|\ \
| | |
| | |
| | | |
Validate multiple contexts on `valid?` and `invalid?` at once
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Example:
```ruby
class Person
include ActiveModel::Validations
attr_reader :name, :title
validates_presence_of :name, on: :create
validates_presence_of :title, on: :update
end
person = Person.new
person.valid?([:create, :update]) # => true
person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]}
```
|
| | |
|
|/ |
|
|
|
|
|
|
| |
These comments do not add a lot to the readability, grepability or
overall understanding of the tests, therefore I believe they can be
safely removed.
|
|
|
|
|
| |
Activemodel is no longer dependent on mocha, so we can make the comments
more generic.
|
|
|
|
| |
Also fix Minitest constant reference.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
As demonstrated by #19570, this option is severely limited, and
satisfies an extremely specific use case. Realistically, there's not
much reason for this option to exist. Its functionality can be trivially
replicated with a normal Ruby method. Let's deprecate this option, in
favor of the simpler solution.
|
|
|
|
| |
without replacement.
|
|\
| |
| |
| | |
Allow symbol as values for `tokenizer` of `LengthValidator`
|
| | |
|
| |
| |
| |
| | |
onwards.
|
|\ \
| | |
| | | |
allow '1' or true for acceptance validation.
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`before_validation` and `after_validation` from
ActiveModel::Validation::Callbacks accept an optional `:on` parameter
that was not previously documented or tested. For instance given
before_validation :do_something, on: :create
then `object.valid?(:create)` will invoke `:do_something` while
`object.valid?` or `object.valid?(:anything_else)` will not.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Before this commit, returning `false` in an ActiveModel validation
callback such as `before_validation` would halt the callback chain.
After this commit, the behavior is deprecated: will still work until
the next release of Rails but will also display a deprecation warning.
The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
|
| |
| |
| |
| |
| |
| |
| |
| | |
This stems from https://github.com/rails/rails/pull/17227#discussion_r21641358
It's simply a clarification of the current behavior by which if an
`after_validation` ActiveModel callback returns +false+, then further
`after_` callbacks **are not halted**.
|
| | |
|
|/
|
|
|
| |
This file was required inside 'test/validators/namespace/email_validator.rb'
that's already required here. Therefore I removed the redundant required.
|
| |
|
| |
|
| |
|
|
|
|
| |
ActiveModel tests can now be run in random order.
|
|
|
|
|
|
|
|
|
|
| |
This gets the whole ActiveModel test suites working even if
`self.i_suck_and_my_tests_are_order_dependent!` is disabled
in `ActiveSupport::TestCase`.
Two places are found that potentially leak global state. This patch
makes sure states are restored so that none of the changes happen in
a single test will be carried over to subsequence tests.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Example:
validates_presence_of :name, on: [:update, :custom_validation_context]
|
|
|
|
| |
fixes 4.0.0 regression introduced in 0317b93c17a46d7663a8c36edc26ad0ba3d75f85
|
| |
|
|
|
|
|
|
| |
Range#include? for non-numeric ranges
added changelog message
|
|
|
|
| |
their setup in their constructor now.
|
|
|
|
|
| |
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
|
|\
| |
| |
| |
| | |
neerajdotname/fix-wrong-test-name-and-failure-message
fix wrong test description and failure message
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|