Rule to verify the name of a property based on the type / format #2461
jayanthpatki91
started this conversation in
Rulesets
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a rule that says that a particular field name should contain the suffix "Date" if the field is of type String and format datetime.
I was wondering if i can somehow capture the information using a function in the "given" keyword:
rules:
check-string-property-suffix:
description: Check if a string property has a particular suffix in its name
type: style
severity: warning
recommended: true
given:
# Select all properties with type string
field: $.properties
function: "patternProperties"
functionOptions:
pattern: "^.$"
match: all
element:
field: type
value: "string"
then:
field: key
pattern: "._suffix$"
message: "Property key '{{key}}' should have '_suffix' as a suffix."
Beta Was this translation helpful? Give feedback.
All reactions