spectral icon indicating copy to clipboard operation
spectral copied to clipboard

Support OR combinator

Open XVincentX opened this issue 5 years ago • 2 comments

It would be very helpful if Spectral could support some sort of OR combinator where I can define multiple functions to apply. If one of them passes, the validation is marked as ✅

  given: >-
      $...parameters[*].name
  then:
    or:
    - function: casing
      functionOptions:
        type: snake
    - function: casing
      functionOptions:
        type: camel

XVincentX avatar Jul 08 '20 16:07 XVincentX

Probably a general thought on other logic functions could be useful (eg. negating function, negating then). Such a mechanism allows to implement or like that:

then_not:
- function: casing
  expect: false
  functionOptions: {type: snake}
- ...

via De Morgan.

ioggstream avatar Jul 08 '20 21:07 ioggstream

We talked about having a "not" today, which is probably related to this.

philsturgeon avatar Sep 14 '20 15:09 philsturgeon