Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !1808

Conditionals mark fields as optional (#1799)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge jm-conditionalrequirement into master Oct 23, 2020
  • Overview 2
  • Commits 2
  • Pipelines 0
  • Changes 5

Created by: jmeinerz

We were assuming that all fields were required when a presence validation existed. While that makes sense, it's also possible for validations to be conditional.

Take the following validation as an example:

validates :phone_number, presence: true, if: :egyptian?

Before this commit, the UI would flag phone_number as required, even for records who were not egyptian.

We now always flag these fields as optional. This is a bit misleading too, but it's impossible to know these things when the page is rendered, and marking them as optional makes for a slightly better user interface, as the user will most likely be prompted with detailed validation errors after trying to persist an invalid item, rather than be led to fill some fields that are, in fact, not mandatory.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: jm-conditionalrequirement