def regex_validator(value):
 try:
  re.compile(value)
 except Exception as e:
  raise ValidationError(e)

def regex_validator ( value ) : try : re . compile ( value ) except Exception as e : raise ValidationError ( e )
validates that the specified regular expression is valid .