prlint icon indicating copy to clipboard operation
prlint copied to clipboard

Expose comparison operators

Open ewolfe opened this issue 7 years ago • 3 comments

Regular expressions are okay, but sometimes they don't cut it. For example:

"additions": [
  {
    "pattern": "0|^[1-9]$|^[1-9]\\d$",
    "message": "Your PR is too big (over 99 additions)"
  }
]

Would be better written as:

"additions": [
  {
    "less-than": 99,
    "message": "Your PR is too big (over 99 additions)"
  }
]

ewolfe avatar Oct 02 '18 05:10 ewolfe

Another option would be to create a custom DSL to safely evaluate comparison operators. For example:

  • "comparison": "$0 < 99"
  • "comparison": "$0 == 'sample string'"
  • "comparison": "$0 > 10 && $0 < 99"
  • "comparison": "'wip' != $0"

ewolfe avatar Oct 02 '18 06:10 ewolfe

https://github.com/joewalnes/filtrex looks like a perfect fit

ewolfe avatar Mar 29 '19 17:03 ewolfe

https://jsonnet.org/ might be appropriate too

ewolfe avatar May 15 '23 18:05 ewolfe