How to use the pathvalidate.InvalidReservedNameError function in pathvalidate

To help you get started, we’ve selected a few pathvalidate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombashi / SimpleSQLite / test / test_validator.py View on Github external
            [reserved_keyword, InvalidReservedNameError]
            for reserved_keyword in INVALID_RESERVED_KEYWORDS_ATTR_UPPER
            + INVALID_RESERVED_KEYWORDS_ATTR_LOWER
        ],
    )
    def test_exception_reserved_invalid_name(self, value, expected):
        with pytest.raises(expected):
            validate_sqlite_attr_name(value)
github thombashi / pathvalidate / test / test_python_var_name.py View on Github external
            [reserved_keyword, InvalidReservedNameError]
            for reserved_keyword in RESERVED_KEYWORDS + ["__debug__"]
        ],
    )
    def test_exception_reserved(self, value, expected):
        with pytest.raises(expected):
            validate_python_var_name(value)
github thombashi / pathvalidate / test / test_js_var_name.py View on Github external
        [[reserved_keyword, InvalidReservedNameError] for reserved_keyword in RESERVED_KEYWORDS],
    )
    def test_exception_reserved(self, value, expected):
        with pytest.raises(expected):
            validate_js_var_name(value)
github thombashi / pathvalidate / test / test_sqlite.py View on Github external
            [reserved_keyword, InvalidReservedNameError]
            for reserved_keyword in INVALID_RESERVED_KEYWORDS_TABLE_UPPER
            + INVALID_RESERVED_KEYWORDS_TABLE_LOWER
        ],
    )
    def test_exception_reserved_invalid_name(self, value, expected):
        with pytest.raises(expected):
            validate_sqlite_table_name(value)
github thombashi / SimpleSQLite / simplesqlite / _sanitizer.py View on Github external
def _validate_table_name(self, table_name):
        try:
            validate_sqlite_table_name(table_name)
        except ValidReservedNameError:
            pass
        except (InvalidReservedNameError, InvalidCharError) as e:
            raise InvalidTableNameError(e)
github thombashi / SimpleSQLite / simplesqlite / _func.py View on Github external
def validate_attr_name(name):
    """
    :param str name: Name to validate.
    :raises NameValidationError: |raises_validate_attr_name|
    """

    try:
        validate_sqlite_attr_name(name)
    except (InvalidCharError, InvalidReservedNameError) as e:
        raise NameValidationError(e)
    except NullNameError:
        raise NameValidationError("attribute name is empty")
github thombashi / SimpleSQLite / simplesqlite / query.py View on Github external
def to_query(self):
        name = self.sanitize(self._value)
        need_quote = self.__RE_NEED_QUOTE.search(name) is not None

        try:
            validate_sqlite_attr_name(name)
        except InvalidReservedNameError:
            need_quote = True
        except (ValidReservedNameError, NullNameError, InvalidCharError):
            pass

        if need_quote:
            sql_name = '"{:s}"'.format(name)
        elif self.__RE_NEED_BRACKET.search(name):
            sql_name = "[{:s}]".format(name)
        elif name == "join":
            sql_name = "[{:s}]".format(name)
        else:
            sql_name = name

        if typepy.is_not_null_string(self.__operation):
            sql_name = "{:s}({:s})".format(self.__operation, sql_name)
github thombashi / pytablereader / pytablereader / _tabledata_sanitizer.py View on Github external
def _validate_table_name(self, table_name):
        try:
            pv.validate_sqlite_table_name(table_name)
        except pv.ValidReservedNameError:
            pass
        except (pv.InvalidReservedNameError, pv.InvalidCharError) as e:
            raise InvalidTableNameError(e)