I’ve seen plenty of solutions on how to validate Form field parameters, but I am not using Django templates or implementing the front-end in Django at all. I’m looking purely for server-side backend validation. Let’s say I have
@api_view(['POST'])
def my_func(request):
And I want the data to be something like:
{
"username" : <user>,
"password" : <pw>,
"age" : <age>
}
I want to validate that username
and password
are strings, perhaps with a minimum length requirement. And that age
is a number, again, perhaps with other restrictions, such as min/max.
Is there a standard way to do this?