| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
onwards.
|
|
|
|
| |
- Changed test to verify complete message instead of verifying if message contains text.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I'm not sure what's the use case for this, but apparently it broke some apps.
Since it was not the intended result from #16210 I fixed it to not raise an
exception anymore. However, I didn't add documentation for it because I don't
know if this should be officially supported without knowing how it's meant to
be used.
In general, validations should be side-effect-free (other than adding to the
error message to `@errors`). Order-dependent validations seems like a bad idea.
Fixes #18002
|
| |
|
|
|
|
| |
- Test case for https://github.com/rails/rails/pull/16851
|
| |
|
|\
| |
| | |
remove unneeded test model for ActiveModel test cases.
|
| | |
|
|\ \
| |/
|/|
| | |
Check for valid options in validate method
|
|/
|
|
|
|
|
|
|
|
|
| |
This change prevents a certain class of user error which results when
mistakenly using the `validate` class method instead of the `validates`
class method.
Only apply when all arguments are symbols, because some validations use
the `validate` method and pass in additional options, namely the
`LenghValidator` via the `ActiveMode::Validations::validates_with`
method.
|
| |
|
|
|
|
|
|
|
|
| |
It's unintuitive to call '#valid?' when you want to run validations but
don't care about the return value.
The alias in ActiveRecord isn't strictly necessary (the ActiveModel
alias is still in effect), but it clarifies.
|
|
|
|
| |
ActiveModel tests can now be run in random order.
|
|
|
|
|
|
|
|
| |
Now that Validator #setup is called from the initializer, we need a
reference to the model's class to be passed in to allow the validators
to continue functioning when used at the instance level.
Closes #14134.
|
| |
|
|
|
|
| |
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' ).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 4e9f53f9736544f070e75e516c71137b7eb49a7a, reversing
changes made to 6b802cdb4f5b84e1bf49aaeb0e994b3be6028af9.
Revert "Don't use tap in this case."
This reverts commit 454d820bf0a18fe1db4c55b0145197d70fef1f82.
Reason: Is not a good idea to add options to this method since we can do
the same thing using method composition.
Person.validators_on(:name).select { |v| v.kind == :presence }
Also it avoids to change the method again to add more options.
|
|
|
|
|
| |
This will filter out the validators on a particular attribute based on
its kind.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Passing a falsey option value for a validator currently causes that validator to
be enabled, just like "true":
ActiveModel.validates :foo, :presence => false
This is rather counterintuitive, and makes it inconvenient to wrap `validates` in
methods which may conditionally enable different validators.
As an example, one is currently forced to write:
def has_slug(source_field, options={:unique => true})
slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
before_validation slugger
validations = { :presence => true, :slug => true }
if options[:unique]
validations[:uniqueness] = true
end
validates :slug, validations
end
because the following reasonable-looking alternative fails to work as expected:
def has_slug(source_field, options={:unique => true})
slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
before_validation slugger
validates :slug, :presence => true, :slug => true, :uniqueness => options[:unique]
end
(This commit includes a test, and all activemodel and activerecord tests pass as before.)
|
| |
|
|
|
|
| |
Fixes #5953
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
In order to deliver debug information to dev team
instead of display error message to end user
Implemented strict validation concept
that suppose to define validation that always raise exception when fails
|
| |
|
| |
|
|
|
|
| |
arguments
|
|
|
|
|
|
| |
serialization to properly handle multiple errors per attribute [#5615 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
I confirmed that this is the behavior on 2.3.x .
[5419 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
's/[ \t]*$//' -i {} \;)
|
|
|
|
|
|
| |
state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
| |
all Ruby core classes.
This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized.
So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
|
|
|
|
|
|
| |
correctly for both string error messages and symbol translated messages.
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
object and a message of error
[#4611 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|
|
| |
fixtures and test helper)
|
|
|
|
| |
dependency
|
|
|
|
| |
individual validation tests and moved them to their own test file
|
|
|
|
|
|
| |
are empty rather than the OrderedHash itself. [#4356 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
'Person.validators_on(:name)'.
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
more dynamic, allowing for customisations during the request [#3514 status:resolved].
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
'Parrots.name' in error messages.
|