Applying conditionals to rules in Spectral


(Taylor) #1

I’d like to apply a rule of checking for an items entry in any definition with type array
Is anyone able to provide an example how rules could be applied conditionally to certain paths?

PS - great tool you all have built


(Taylor) #2

I think I’ve figured it out using when. Would be great to document these once they’re set in stone in the Wiki or ReadMe https://github.com/stoplightio/spectral/blob/next/src/types/rule.ts


(Taylor Barnett) #3

Nice! Sorry about the delay. We definitely want to expand on the docs to help right custom rules. I also want to document the custom functions better.

I’m curious, could you share the code for your rule?