ytdl-sub/src/ytdl_sub/validators/source_variable_validator.py
Jesse Bannon 53adbbcb22
[FEATURE] Regex capture and filtering on source variables plugin (#100)
* actually working

* changed plugin format. Need unit tests, documentation, update e2e to filter

* refactor plugin name, matching now working

* description work in progress, need more intricate testing

* tests looks good, regenerate output

* e2e tested, need more failure tests, no dupe variable names, add docs

* unit tests passing again

* more fail tests

* updated with name, default, better docs

* sanitized vars created
2022-07-16 23:39:46 -07:00

20 lines
858 B
Python

from ytdl_sub.utils.exceptions import InvalidVariableNameException
from ytdl_sub.validators.string_formatter_validators import is_valid_source_variable_name
from ytdl_sub.validators.validators import ListValidator
from ytdl_sub.validators.validators import StringValidator
class SourceVariableNameValidator(StringValidator):
_expected_value_type_name = "source variable name"
def __init__(self, name, value):
super().__init__(name, value)
try:
_ = is_valid_source_variable_name(self.value, raise_exception=True)
except InvalidVariableNameException as exc:
raise self._validation_exception(exc) from exc
class SourceVariableNameListValidator(ListValidator[SourceVariableNameValidator]):
_inner_list_type = SourceVariableNameValidator
_expected_value_type_name = "source variable name list"