Rule order matters in schema?

Following two schemata are identical except order of :format? and :min_size? but their outputs are different.

Is this intended?

require "dry/schema"

Dry::Schema.load_extensions(:hints)

format_first = Dry::Schema.Params do
  required(:foo).filled(:string, format?: /\A[A-Z][a-z]+/, min_size?: 3)
end

size_first = Dry::Schema.Params do
  required(:foo).filled(:string, min_size?: 3, format?: /\A[A-Z][a-z]+/)
end

params = {foo: "fo"} # this value violates both format and mininum size constraints

result1 = format_first.call(params)
puts "format first:"
puts "errors: %p" % [result1.errors.to_h]
puts " hints: %p" % [result1.hints.to_h]

result2 = size_first.call(params)
puts "size first:"
puts "errors: %p" % [result2.errors.to_h]
puts " hints: %p" % [result2.hints.to_h]

Output:

format first:
errors: {:foo=>["is in invalid format"]}
 hints: {:foo=>["size cannot be less than 3"]}
size first:
errors: {:foo=>["size cannot be less than 3"]}
 hints: {} # expected to see "is in invalid format"

Versions:

  • Ruby 3.3.0
  • dry-logger (1.0.3)
  • dry-schema (1.13.3)
  • dry-validation (1.10.0)