Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

Dynamic Predicate Arguments

It's often the case that arguments that are passed to predicates are not known in the moment of defining a schema rules. If you need to calculate some arguments dynamically at run-time, you can simply define methods in your schema and refer to them in the DSL:

DataSchema = Dry::Validation.Schema do
  configure do
    def data
      %w(a b c)

  required(:letter).filled(included_in?: data)

DataSchema.(letter: 'f').messages
# {:letter=>["must be one of: a, b, c"]}

octocatEdit on GitHub