Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django regexvalidator example

# for outside model uses
from django.core.validators import RegexValidator

validate_alphanumeric = RegexValidator(r'^[a-zA-Z0-9]*$', 'Only alphanumeric characters are allowed.')
validate_alphanumeric("foo") # ok, nothing happens
validate_alphanumeric("++") # raises a ValidationError

ValidationError: [u'Only alphanumeric characters are allowed.']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #regexvalidator
ADD COMMENT
Topic
Name
1+1 =