Skip to content

Filter for a property inside a Composition inside an array is not executed #70

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

Closed
wol-soft opened this issue Apr 20, 2023 · 0 comments · Fixed by #71
Closed

Filter for a property inside a Composition inside an array is not executed #70

wol-soft opened this issue Apr 20, 2023 · 0 comments · Fixed by #71
Assignees
Labels
bug Something isn't working

Comments

@wol-soft
Copy link
Owner

wol-soft commented Apr 20, 2023

Describe the bug
Independent of a provided value or a default value the value for created is not transformed resulting in a fatal error when calling the generated getCreated:

Uncaught TypeError: ...::getCreated(): Return value must be of type ?DateTime, string returned

The issue also affects non-transforming filters like trim.

Expected behavior

The transformed filter should be executed and consequently a DateTime object should be returned.

Schema

{
  "type": "object",
  "properties": {
    "songs": {
      "type": "array",
      "items":{
        "allOf": [
          {
            "type": "object",
            "properties": {
              "title": {
                "type": "string"
              }
            },
            "required": [
              "title"
            ]
          },
          {
            "type": "object",
            "properties": {
              "created": {
                "type": "string",
                "filter": "dateTime",
                "default": "now"
              }
            }
          }
        ]
      }
    }
  }
}

Version:
0.23.2

@wol-soft wol-soft added the bug Something isn't working label Apr 20, 2023
@wol-soft wol-soft self-assigned this Apr 20, 2023
@wol-soft wol-soft changed the title Transforming filter for a property inside a Composition inside an array is not executed Filter for a property inside a Composition inside an array is not executed Apr 20, 2023
wol-soft added a commit that referenced this issue Apr 20, 2023
Merged properties of a composition are filled up with the provided values without further validation execution after the single composition branches are validated separately. Consequently,changes applied to the values from filters are missing. The new added method _getModifiedValues sets up a diff with all changed values from the nested composition branch. All modified values are applied to the merged property afterwards so changes from filters are kept.
@wol-soft wol-soft linked a pull request Apr 20, 2023 that will close this issue
wol-soft added a commit that referenced this issue Apr 26, 2023
The getModifiedValues method must be scoped to be added to the correct model. Additionally, it must be added with a unique key per validator as multiple composed validators in a single model might occur.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant