-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: panic on oneof validation #86
Conversation
@LucasRoesler I just realized that this way of fixing the issue effectively makes any |
is it possible to toggle the error behavior based on the not null property? |
@megaflo actually now that i think about it, i don't think we need to change anything, the required validation should already work as expected, e.g if you have Container:
type: object
properties:
error:
$ref: "#/components/schemas/Error" then func (m Container) Validate() error {
return validation.Errors{
"error": validation.Validate(
m.Error,
),
}.Filter()
} should skip validation is m.Error is empty, this is part of the behavior of the ozzo-validation |
The generated validation for
oneof
schemas produces an error, if used as a property in another object and left empty (e.g. by omitting that property from the json payload). The cause is a nil initialized interface in the implementation, that gets dereferenced.This PR adds extra checks to make sure the
nil
interface is never dereferenced.Ticket
How Has This Been Verified?
A new test has been added to verify the expected behavior (a validation error is returned for missing
oneof
fields).Checklist: