skippyPeanutButter / yaml_bot

Validate the content of a yaml file according to a set of rules
MIT License
3 stars 0 forks source link

Key value validation #18

Closed skippyPeanutButter closed 7 years ago

skippyPeanutButter commented 7 years ago

Previous behavior only allowed yamlbot to check that a particular value for a key was of a specific type. Example: validating that the travis-ci language key value given is a string

root_keys:
  optional:
    language:
      accepted_types:
        - String

This change will allow users to specify a list of values to validate a key against.

Example: validating the travis-ci language key against a list of valid languages.

root_keys:
  optional:
    language:
      values:
        - 'android'
        - 'ruby'
        - 'python'
        - 'go'
        - 'java'

This will also give users the ability to validate a key contains any value

Example:

root_keys:
  optional:
    language:
      values:
        - '*'

Example: check version key contains any integer number

root_keys:
  required:
    version:
      accepted_types:
        - Fixnum
      values:
        - '*'

Example: check travis-ci script key contains any string

root_keys:
  required:
    script:
      accepted_types:
        - String
      values:
        - '*'
skippyPeanutButter commented 7 years ago

Addresses https://github.com/skippyPeanutButter/yaml_bot/issues/14

samrocketman commented 7 years ago

I've cut a few issues which I think can help improve how these rules are defined. For now, the changes as-is look good.