Validation¶
flutils offers the following validation functions.
flutils.
validate_identifier
(identifier, allow_underscore=True)[source]¶Validate the given string is a proper identifier.
This validator will also raise an error if the given identifier is a keyword or a builtin identifier.
Parameters:
- identifier (str) – The value to be tested.
- allow_underscore (bool, optional) – A value of
False
will raise an error when theidentifier
has a value that starts with an underscore_
. (UseFalse
when validating potentialnamedtuple
keys) Default:True
.Raises:
SyntaxError
– If the given identifier is invalid.TypeError
– If the given identifier is not astr
.Return type:
None