Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self, form, field):
"""Validate.
:param field: validated field.
:param form: validated form.
"""
doi = field.data
if doi and not doi_regexp.match(doi):
# no point to further validate DOI which is invalid
raise StopValidation(self.message)