beacon-APIs icon indicating copy to clipboard operation
beacon-APIs copied to clipboard

Create spectral rule to enforce quotes

Open mpetrunic opened this issue 5 years ago • 1 comments

Rule should be in .spectral.yml in root directory of repository.It should throw error if non double quotes are used.

More about spectral rules.

mpetrunic avatar May 22 '20 11:05 mpetrunic

To enforce the use of double quotes in your repository, you can create a rule in the .spectral.yml file. Here's an example of how you can define the rule:

rules:
  enforce-double-quotes:
    given: "$..[?(@.type == 'string')]"
    then:
      field: "pattern"
      function: "pattern"
      functionOptions:
        match: "^[^\"]*$"
        message: "Double quotes must be used for string values."

This rule targets all string values in your repository and checks if they contain any characters other than double quotes. If any non-double quote characters are found, it will throw an error with the specified message.

Make sure to place this rule in the .spectral.yml file in the root directory of your repository.

staccDOTsol avatar Jul 31 '23 19:07 staccDOTsol