It is great that it is possible to create custom validation using the "x-validate" vendor extension. But having created a custom validator, I would like to be able to also have a custom error message, so the user will have an easier time of understanding how to fix it.
From a quick check I think this could be easily done by adding an additional reason option to OpenApiSpex.Cast.Error.reason. Maybe :custom, and then adding a function head for creating messages with a %{reason: :custom, meta: %{message: message}} error, that just returns the message.
Do you think it makes sense to add something like this, or am I missing something?
P.S.: I am happy to make the PR if adding this makes sense.
It is great that it is possible to create custom validation using the "x-validate" vendor extension. But having created a custom validator, I would like to be able to also have a custom error message, so the user will have an easier time of understanding how to fix it.
From a quick check I think this could be easily done by adding an additional reason option to
OpenApiSpex.Cast.Error.reason
. Maybe:custom
, and then adding a function head for creating messages with a%{reason: :custom, meta: %{message: message}}
error, that just returns the message.Do you think it makes sense to add something like this, or am I missing something?
P.S.: I am happy to make the PR if adding this makes sense.