This reverts commit d453eb5ad78125794b0320e134a8a0962f11a446, reversing
changes made to a81be79d4b553fe1bf296e387babaa9b073934b2.
`app/validators` have no special meaning. The code search for
a constant with the suffix `Validator` using `const_get`, so it
can be in any folder that would be autoloaded using that name.
I don't write custom validators often, but have read this doc many times and it never occurred to me that validators could be autoloaded if placed in `app/validators` until I stumbled on it when trying to figure out how to "register" them (e.g. `EmailValidator` to `email:`). (Separately, it might be worth mentioning explicitly that the kwarg is derived from the class name).
The Active Record Validations guide use `Person < ApplicationRecord`
in all examples. When reading about Custom Validators, one of the
examples had a different configuration. By using the same example
everywhere, this change helps the user save time and feel more confident
using the feature.
`validates_associated` makes sure that passed associations are validated
everytime the record is saved. This is unlike other validations that
validate an attribute/association has a certain value.
Typically you won't call:
validates :books, associated: true
By grouping `validates_associated` with `validates_with` and
`validates_each` it's made clearer `validates_associated` is a bit
different.
With this change the validations are sorted alphabetically.
existing email regex allowed for invalid emails and invalidated valid emails
- The following emails are shown to be valid emails when they are not:
- `email_<script></script>_123@example.co.in`
- `email"123@example.com`
- `email..123@example.com`
- `.email123@example.com`
... and a few more
- The following email is shown to be an invalid email when it is valid:
- `email@123.123.12.123`
Lets use the default ruby regex instead
We allow for compare validations in NumericalityValidator, but these
only work on numbers. There are various comparisons people may want
to validate, from dates to strings, to custom comparisons.
```
validates_comparison_of :end_date, greater_than: :start_date
```
Refactor NumericalityValidator to share module Comparison with ComparabilityValidator
* Move creating the option_value into a reusable module
* Separate COMPARE_CHECKS which support compare functions and accept values
* Move odd/even checks to NUMBER_CHECKS as they can only be run on numbers
This links the first mention of each method to its API documentation,
similar to a Wikipedia article. Some subsequent mentions are also
linked, when it suits the surrounding text.
Follow-up to #39620.
This commit changes a few overlooked code fences to `bash`, and changes
a few IRB session snippets to be only Ruby code with a `ruby` fence.
In the past, we sometimes hit missing `Symbol#start_with?` and
`Symbol#end_with?`.
63256bc5d7a8e812964d
So I proposed `Symbol#start_with?` and `Symbol#end_with?` to allow duck
typing that methods for String and Symbol, then now it is available in
Ruby 2.7.
https://bugs.ruby-lang.org/issues/16348
Using `String#starts_with?` and `String#ends_with?` could not be gained
that conveniency, so it is preferable to not use these in the future.
Mark private constants
Display alternative for deprecation removal warning
Annotate Error's attributes
More emphasis on adding an error instead of message
Rewrite scaffold template using new errors API
Set first and last with behavior change deprecation
Update more doc and example
Add inspect for easier debugging
Using words such as 'just', 'simply' and 'easy' implies to the reader
that the tasks they are trying to accomplish are tasks that anyone can
do, which might then frustrate them if they find it difficult to
complete.
This commit rephrases some usage of these words to aid understanding in
the readers without making them feel belittled.
[ci skip]
Accessing the MySQL manual without a specific version number will redirect to the latest version of the manual.
Remove non functional id from a comment in favor an explicit message
I think that it is not clear what means that _an association is
present_. Add that it is checking that the foreign key is not empty and
that the referenced object exists to clarify it.
As `Lambdas` are a type of `Proc`, they can also be used in the
`if`/`unless` option of a validation to decide when the validation is
executed. Add this case to the guide for clarification.
Closes https://github.com/rails/rails/issues/33212