-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The purpose of this module is to provide easy ways to validate strings are in the correct format for use.
TODO
- Create a validation class that can take in a regex string, and has 2 methods:
__repr__(), validate() - Add in the instances found in the Validation instances section
Validation class
import re
from dataclasses import dataclass
@dataclass
class Validator:
validation_string:str
def validate(self, value:str, as_bool:bool=False) -> :
compiled_expression = re.compile(self.validation_string)
if not as_bool:
return compiled_expression.match(value) # Return full match groups
else:
return bool(compiled_expression.match(value))
def __repr__(self) ->str:
return self.validation_stringValidation instances
- Valid email checker https://www.regextester.com/19
- Valid hostname regex https://www.regextester.com/23
- Add IP validation to dns module https://github.com/richardpenman/whois/blob/master/whois/__init__.py#L27-L28
- Phone number validation for Tel Links (note this is only for 6-7 digit numbers) https://www.regextester.com/17
- Look at international phone number validation (has some false positives) https://www.regextester.com/1978
- Finds HTML/XML tags https://www.regextester.com/27540
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels