Page cover

⚠️Prompt

Prompt validations validate the input / output data and give users details about the violations according to user passed rules.

YAML Specifications

Currently there are two sections in validation suits specifications through YAML those are :

format-rules

format-rules contain rules that checks validation related to the formatting of input/output. One example could be we can validate if the given json contains all the expected keys or not.

  1. To use format rules we need to define format-rules section in our YAML file.

  2. After adding format-rules section we need to add the rule i.e, key-validate rule. ( key-validate rule is for validating if all the keys expected in data are present or not)

rules.yaml
format-rules:
    - key-validate : [username, id, email ]

validation-rules

validation-rules section contains different rules to validate the data against constraints provided in rules. For a simple example rule could be like validating the length of data or checking percentage of sentiment, complexity of the text.

  • datatype - in datatype rule parameter we can validate our input for certain datatype. Expected set of values (’string’, ‘integer’, ‘boolean’, ‘float’)

  • len-validate - If we want to validate length of the input, We can use this field to validate the length of input / output.

    • len-validate has four attributes

      • gt - greater than value

      • lt - less than value

      • gte - greater than equal to value

      • lte - less than equal to

  • choice-validate - Validating the input/output is from the expected set of values. In choice validate we can pass set of values as list those are acceptable.

  • range-validate - Validating an integer of an float value is between certain limit.

    • range-validate has four attributes same as len-validate gt’, ‘lt’, ‘gte’, andlte’.

  • text-complexity-validate - Validating the text complexity of text phrases.

  • sentiment-polarity-validate - For validating sentiment polarity range of an input/output “sentiment-polarity-validate” key can be used.

  • profanity-validate -for validating the profanity in phrase we can use this validation option.The value is returned in percentage so the values of range should be in consideration of 1 to 100 percentage.

How to Use

  • Validation methods can be used for both input and output validations. Its as simple as inheriting a library and passing your data.

Input / Output Validation

Last updated

Was this helpful?