Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic config value validation #62

Open
lehins opened this issue Aug 29, 2018 · 0 comments
Open

Basic config value validation #62

lehins opened this issue Aug 29, 2018 · 0 comments

Comments

@lehins
Copy link
Contributor

lehins commented Aug 29, 2018

This is just an idea, but it could be valuable.
Have a small collection of declarative validators that can be specified directly in the spec. Validators are simply functions that evaluate to Bool and are applied to the value that was parsed successfully. For example range or compare for numbers and other Ord things, length for strings and lists, eg:

    port:
      etc/spec:
        default: 3000
        type: number
        validators:
        - lte:
            value: 0
            error: "Ports with non-positive values don't make sense"
        - gt:
            value: 65535
            error: "Port numbers are 16-bit"
        - lt:
            value: 1024
            warn: "Using system level port, root privilege will be necessary"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant