Whenever we write belongs_to :association, required: true
``
or
belongs_to :association, optional: false
``
Rails will add a presence validator for that association.
My suggestion is that required or optional option should be able to take a Proc to be passed to the presence validator’s if/unless option.
Example:
belongs_to :association, required: proc { condition }
Equivalent to
belongs_to :association validates :association, presence: true, if: proc { condition }
``