0

I am trying to do validations , some duplicate keys should not be available in yaml object, so when I am trying to add the values in array it behaves like set and removes the duplicates. I wanted to find out the duplicate key .

test:
 - name : someName
   code: SomeCode
 - name : someNameNew
   code: SomeCodeNew
 - name : someName
   code: SomeCodeNew


So I want to fail OPA policy with the message someName is duplicate in yml

getListOfArray[arr] {

arr := test.name[_]

}

print(getListOfArray) gives value [someName, someNameNew]

i am expecting [someName, someNameNew, someName]

0 Answers0