def validate(self, document): try: int(document.text) except ValueError: raise ValidationError(message='Please enter a number', cursor_position=len( document.text)) # Move cursor to end
def validate(self, document): ok = regex.match( '^([01]{1})?[-.\s]?\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$', document.text) if not ok: raise ValidationError(message='Please enter a valid phone number', cursor_position=len( document.text)) # Move cursor to end
def validate(self, document): try: input_type(document.text) except Exception as e: print(e) raise ValidationError( message=f'please enter a valid {input_type}', cursor_position=len(document.text))
def validate(self): error_message = "A Infura Project ID is a sequence of 32 hex characters long" if not Infura.is_valid_project_id(self.text): raise ValidationError(error_message)
def validate(self, document, *args, **kwargs): if not document.text: raise ValidationError(message='This field is required', cursor_position=len(document.text))