Skip to content

πŸ“˜ Function documentation

Name: πŸ“¦ are_params_valid(body,validation_rules)?

Descripcion

This function validates the parameters of incoming requests before
the RESTful API processes them. Based on defined structural and business rules,
it ensures that the input data meets the requirements for the API to function correctly.

β†’] Input as 🧾Body Extraction in Edit Fields (Set) in mode JSON

{
  "email": "jacardona@.logyca.com",
  "name": "an",
  "surname": "cardona",
  "age": 32,
  "age_text": "32",
  "value": 1.1,
  "value_text": "1.1",
  "is_active": "true",
  "has_error": False
}

β†’] Input as πŸ“‹ validation_rules in Edit Fields (Set) in mode JSON

{
    "validation_rules": [
        {
            "field": "name",
            "data_type": "str",
            "is_mandatory": true,
            "min_length": 3,
            "max_length": 250
        },
        {
            "field": "email",
            "data_type": "email",
            "is_mandatory": true,
            "min_length": 3,
            "max_length": 250
        },
        {
            "field": "is_active",
            "data_type": "bool",
            "is_mandatory": true
        },
        {
            "field": "age",
            "data_type": "int",
            "is_mandatory": true
        },
        {
            "field": "age_text",
            "data_type": "int",
            "is_mandatory": true
        },
        {
            "field": "value",
            "data_type": "float",
            "is_mandatory": true
        },
        {
            "field": "value_text",
            "data_type": "float",
            "is_mandatory": true
        }
    ]
}