Skip to content

new: when validating a ref object update attribute path in data#25

Open
primalmotion wants to merge 2 commits intomasterfrom
validation-err-attribute-path
Open

new: when validating a ref object update attribute path in data#25
primalmotion wants to merge 2 commits intomasterfrom
validation-err-attribute-path

Conversation

@primalmotion
Copy link
Contributor

It is convention that elemental.Error Data can hold a map[string]any or map[string]string that may have a key 'attribute' giving the attribute name to which the error relates to.

This patch adds a function that update the attribute key to hold the full path of the position of the error in the object.

For instance, if you miss parent.children[0].name that is required, instead of having the attribute key set to 'name' it will be set to 'parent/children/0/name'.

@primalmotion
Copy link
Contributor Author

primalmotion commented Feb 5, 2026

@chris-acuvity please test.

  • go install that elegen
  • point elemental to this branch in backend go.work
  • make api in the backend
  • test

@chris-acuvity
Copy link
Contributor

I tried to generate the errors and it looks good!

[
    {
        "code": 422,
        "data": {
            "attribute": "components/0/selector/kubernetes"
        },
        "description": "Kubernetes app component selector must be defined if app component selector 'type' is set to 'Kubernetes'.",
        "subject": "api",
        "title": "Validation Error",
        "trace": "unknown"
    },
    {
        "code": 422,
        "data": {
            "attribute": "selector"
        },
        "description": "component 'dsada' has an invalid Kubernetes selector (workload group hash computation failed)",
        "subject": "api",
        "title": "Validation Error",
        "trace": "unknown"
    }
]

@primalmotion primalmotion force-pushed the validation-err-attribute-path branch from e6a4f09 to f0b1936 Compare February 5, 2026 22:31
It is convention that elemental.Error Data can hold a map[string]any or
map[string]string that may have a key 'attribute' giving the attribute
name to which the error relates to.

This patch adds a function that update the attribute key to hold the
full path of the position of the error in the object.

For instance, if you miss parent.children[0].name that is required,
instead of having the attribute key set to 'name' it will be set to
'parent/children/0/name'.
@primalmotion primalmotion force-pushed the validation-err-attribute-path branch from f0b1936 to 9ed2731 Compare February 5, 2026 22:32
@chris-acuvity
Copy link
Contributor

@devyansh3,

Can you try to see if it works for you on Acumux too? We want to make sure it's fine before merging this PR

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

Successfully merging this pull request may close these issues.

2 participants