def validate_domain(value):
 if (not re.search(u'^[a-zA-Z0-9-\\.]+$', value)):
  raise ValidationError(u'"{}" contains unexpected characters'.format(value))

def validate_domain ( value ) : if ( not re . search ( u'^[a-zA-Z0-9-\\.]+$' , value ) ) : raise ValidationError ( u'"{}" contains unexpected characters' . format ( value ) )
error if the domain contains unexpected characters .