Skip to content

Not able to get field path when I use custom messages for array type. #839

@Sayi-k

Description

@Sayi-k

For other types I can add path manually to custom message, but for arrays I need its index to be printed as well.
Schema Example:

"requestedItems": {
  "type": "array",
  "minItems": 1,
  "items": {
    "properties": {
      "item": {
        "type": "string",
        "minLength": 1,
        "message": {
          "minLength": "Item should not be empty"
        }
      }
    }
  }
}

As per the above code when I do not put any value in the item field in the request I get below custom message as specified
"Item should not be empty"

But I want custom message to be printed along with its path, for ex:
"$.requestedItems[0].item: Item should not be empty"

Path gets printed if I remove custom message. A dynamic message created by library would be printed along with field path as shown below.
"$.requestedItems[0].item: must be at least 1 characters long"

But I want the path with custom message. I can add the path along with custom message but for array I can not pass its index. Please help

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions