Checks¶
Checks are used to validate data within a field while it is being processed.
Built-in¶
horkos provides several built-in checks.
- between:
Confirm that the given value is between two other values. Accepts
upperandlowerspecifying the upper and lower limits for values to be between.checks: - name: between args: upper: upper_value lower: lower_value
- choice:
Confirm that the given value is in a list of valid options. Accepts
optionsargument listing all valid choices.checks: - name: choice args: options: - option_1 - option_2
- email:
Confirm that the given value is a valid email address.
checks: - email
- iso_timestamp:
Confirm that the given value is a valid iso timestamp. A valid example is
2020-10-25T20:27:21Z.checks: - iso_timestamp
- json:
Confirm that the given value is a valid JSON string. Accepts no arguments.
checks: - json
- json_array:
Confirm that the given value is a valid JSON string that can be deserialized to an array. Accepts no arguments.
checks: - json_array
- json_object:
Confirm that the given value is a valid JSON string that can be deserialized to an object. Accepts no arguments.
checks: - json_object
- maximum:
Confirm that the given value is less than the specified limit. Accepts
limitargument specifying the maximum value and ainclusiveboolean to determine if values matching the maximum should be allowed.checks: - name: maximum args: limit: max_value inclusive: true # defaults to true
- maximum_length:
Confirm that the given value is of a length less than or equal to the specified limit. Accepts
limitargument specifying the maximum length a string is allowed to be.checks: - name: maximum_length args: limit: max_length
- minimum:
Confirm that the given value is greater than the specified limit. Accepts
limitargument specifying the minimum value and ainclusiveboolean to determine if values matching the minimum should be allowed.checks: - name: minimum args: limit: max_value inclusive: true # defaults to true
- regex:
Confirm that the given value matches a specific regex. Accepts
regexargument specifying the pattern values must match and an optionalignore_caseboolean to determine if case should be ignored when matching the regex.checks: - name: regex args: regex: pattern_to_match ignore_case: false # defaults to false
- uuid:
Confirm that the given value is a valid uuid.
checks: - uuid