The repository has not been cloned yet. Run the following command first
to clone the repo, check out the target commit, and install dependencies:
bash
bash /setup_files/setup.sh
The code will then be available at /testbed.
You are working on the repository CSenshi/Validator (instance: CSenshi__Validator-32).
The code is located in /testbed.
##27 Implement function validate() without class
let's write validate() function in validator/validator.py. Currently we have Validator class and if anyone wants to use our library they should use it as follwos Validator(req,rules).validate().
I suggest writing wrapper function, that takes in request and rule dictionaries and returns True/False.and use it as validate(req,rules)
As of error messages we can do 3 things:
return error messages with True/False
python
result, err_msg = validate(req, rules)
return True/False and if user passes third argument as dictionary fill it with error messages
python
errors = {}
result = validate(req, rules, errors)
return True/False and add user ability to choose whether or not return error messages
python
result = validate(req, rules)
result = validate(req, rules, False)
result, err_msg = validate(req, rules, True)