The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ
from masonite.validation import Validator
from masonite.validation import required, accepted
from masonite.request import Request
from masonite.response import Response
def show(self, request: Request, response: Response, validate: Validator):
"""
Incoming Input: {
'user': 'username123',
'email': 'user@example.com',
'terms': 'on'
}
"""
errors = request.validate(
validate.required(['user', 'email']),
validate.accepted('terms')
)
if errors:
return response.back().with_errors(errors)
Specifically, this two lines will raise an error, because required and accepted are not attributes of Validator class. Instead, you should import the class from masonite.validation, but, in order to make it work more naturally, I propose this fix to make it work.
In docs, you could see something like this:
Specifically, this two lines will raise an error, because required and accepted are not attributes of Validator class. Instead, you should import the class from
masonite.validation
, but, in order to make it work more naturally, I propose this fix to make it work.