feat: add validation support in marker type#357
feat: add validation support in marker type#357MahmoudShakour wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "validation marker with one value", |
There was a problem hiding this comment.
Can you add a test for multiple validation markers, and a test for using quotes (e.g. self == "foobar")?
|
I didn't realize it when writing my feature request, but the fact that each validation is a struct with at least rule and typically also message means that this syntax needs to be updated to support that too |
|
@fsommar |
|
@MahmoudShakour nested quotes is going to be hard to parse for both humans and machines, I think. What about updating the right-hand side to support either strings, like today, or JSON objects? The JSON object suggestion would look something like this: immutableFoo: |
string |
validation={
"rule": "self == oldSelf",
"message": "can't be changed"
}Another suggestion, where the index is arbitrary as long as it's unique (could be 0 and 1 also): immutableBar: |
integer
validation[immutability].rule="self == oldSelf"
validation[immutability].message="can't be changed"
validation[positive].rule="self > 0 || self == -1"
validation[positive].message="has to be positive or -1" |
|
Hi @MahmoudShakour - are you still working on this one? |
|
@a-hilaly If @MahmoudShakour is okay with it, I’d be happy to take this on since I have priorly worked with Markers logic in PR #424 |
|
please go for it @DhairyaMajmudar - can you please make sure to add @MahmoudShakour as co-author or fork his branch so that we can preserve some of his work. |
|
Thank you, yeah sure will add him as commit co-author |
fixes: #347