Skip to content

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

Open
@yevhenii-nadtochii

Description

@yevhenii-nadtochii

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions