forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit 20aa34e

Merge pull request rails#52951 from Ridhwana/Ridhwana/active-record-validations [ci-skip]
- Initial examples should probably use Person.new instead of Person.create
(create already runs validations under the hood, and will insert the record
in the DB if all pass)
- Rails team => Rails framework
- `exclusion` has a paragraph about using procs, lambdas, etc. that `inclusion`
doesn't... they use the same logic for validation.
- We have a [guide on I18n](https://edgeguides.rubyonrails.org/i18n.html),
including info about error messages, that we could maybe link from the
validations when talking about messages.
- We talk about using errors in views by the end, could be an opportunity to
mention
`[field_error_proc](https://edgeguides.rubyonrails.org/configuring.html#config-action-view-field-error-proc)`
since that seems to only be mentioned in the configuring guide.
- Add a section called Custom Contexts
- The "Why Use Validations?" section mentions alternatives to validations. This
could probably use an extra header: "Alternatives to Validations"
- The line mentioning more use-cases for :on can probably be removed: "We will
cover more use-cases for on: in the [callbacks
guide](https://edgeguides.rubyonrails.org/active_record_callbacks.html).", as
we'll add a section for "Validation Contexts" as mentioned above.
- Should "Conditional Validations" be mentioned before "Strict Validations" and
"Common Validation Options"? Conditionals are common validations options and
probably more common than `allow_nil` and `strict`. "Common Validation
Options" isn't very descriptive either. (I moved Conditional Validations
before Strict Validations but kept Common Validation Options where it is for
the natural flow)
- "Listing Validators" doesn't seem related to "Performing Custom Validations".
Maybe it should it's own top-level section?
- The [Errors where and error
object](https://edgeguides.rubyonrails.org/active_record_validations.html#errors-where-and-error-object)
section uses both 2 and 3 in the example, but should be 3 everywhere?
- Move usage of `errors.add` to the top, as it's used before the explanation in
"Working with Validation Errors"?
Co-authored-by: Petrik de Heus <[email protected]>
Co-authored-by: John Gallagher <[email protected]>
Co-authored-by: Ridhwana Khan <[email protected]>
Co-authored-by: bhumi1102 <[email protected]>
Co-authored-by: Harriet Oughton <[email protected]>
Co-authored-by: zzak <[email protected]>File tree
Expand file treeCollapse file tree
1 file changed
+776
-511
lines changedFilter options
- guides/source
Expand file treeCollapse file tree
1 file changed
+776
-511
lines changed
0 commit comments