Skip to content

The (validate) option has no way to report a type name of the unpacked Any #218

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

Open
yevhenii-nadtochii opened this issue Apr 29, 2025 · 0 comments

Comments

@yevhenii-nadtochii
Copy link
Contributor

yevhenii-nadtochii commented Apr 29, 2025

The (validate) option does nested validation of message fields. An additional feature of this option is that it can unpack the message if the field type is Any. It tries to find a Java class for the given Any, unpack if found, and invoke validate() if the unpacked object implements ValidatableMessage.

The problem is that the ConstraintViolation instance has no place where to put the name of the unpacked type.

Currently, we fill in two fields:

  1. typeName - the root type that triggered validation.
  2. fieldPath – the path to the invalid field relatively to the typeName.

An example of the failing validation with Any:

io.spine.validate.ValidationException: ValidationException: At `spine.server.dispatch.InboxAddresses`: 
At `id.simple_name`: The field `spine.server.dispatch.InboxAddresses.id.simple_name` of the type `string` must have a non-default value.

In this example, spine.server.dispatch.InboxAddresses.id.simple_name is the failed field, where spine.server.dispatch.InboxAddresses.id is Any. So, it is not clear what type had the invalid simple_name field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant