Skip to content

Commit

Permalink
Merge pull request #52951 from Ridhwana/Ridhwana/active-record-valida…
Browse files Browse the repository at this point in the history
…tions [ci-skip] (#53497)

- 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: John Gallagher <john@synapticmishap.co.uk>
Co-authored-by: Ridhwana Khan <ridhwana@Ridhwana-Ks-MBP.lan>
Co-authored-by: bhumi1102 <bhumi1102@gmail.com>
Co-authored-by: Harriet Oughton <73295547+OughtPuts@users.noreply.github.com>
Co-authored-by: zzak <zzakscott@gmail.com>
  • Loading branch information
6 people authored Oct 30, 2024
1 parent f6916e7 commit ad485aa
Showing 1 changed file with 776 additions and 511 deletions.
Loading

0 comments on commit ad485aa

Please sign in to comment.