-
-
Couldn't load subscription status.
- Fork 115
Open
Labels
Description
Describe the bug
We have run into the same issue as #230, but with uuid_v3? and uuid_v5? this time.
To Reproduce
We have run into the bug with code similar to the following one:
require 'dry/schema'
class ExampleService
include ::Dry::Monads[:do, :result]
CONTRACT =
Dry::Schema.Params do
optional(:filters).hash do
optional(:id).filled { uuid_v3? | uuid_v4? | uuid_v5? }
# ...
end
end
private_constant :SCHEMA
def call(**input)
valid_data = yield validate(input)
process(input)
end
def validate(input)
result = CONTRACT.call(input)
if result.success?
Success(result.to_h)
else
Failure(:invalid_params)
end
end
def process(input)
# ...
end
endupon a call with id in some non-uuid format. The following error message was produced:
API error: Message template for :id under "filters" was not found. Searched in:
"en.dry_schema.errors.rules.id.uuid_v3?.arg.default"
"en.dry_schema.errors.rules.id.uuid_v3?"
"en.dry_schema.errors.uuid_v3?.failure"
"en.dry_schema.errors.uuid_v3?.value.id"
"en.dry_schema.errors.uuid_v3?.value.string.arg.default"
"en.dry_schema.errors.uuid_v3?.value.string"
"en.dry_schema.errors.uuid_v3?.arg.default"
"en.dry_schema.errors.uuid_v3?"
Expected behavior
Proper error message is produced, no exception thrown.
Looking at possible predicates vs the default error messages, how about adding the default messages for v1, v2, v4 and v5?
My environment
- Affects my production application: YES
- Ruby version: 3.1.2
- OS: Linux
Zerocules