Skip to content

PasswordField

Field of Model for enter password.

PasswordField

Bases: Field

Field of Model for enter password.

Attention
  • Regular expression: ^[-._!"`'#%&,:;<>=@{}~$()*+/\?[]^|a-zA-Z0-9]{8,256}$
  • Valid characters: a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \ ? [ ] ^ |
  • Number of characters: from 8 to 256.
Source code in src/ramifice/fields/password_field.py
class PasswordField(Field):
    r"""Field of Model for enter password.

    Attention:
        - `Regular expression:` ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
        - `Valid characters:` a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \\ ? [ ] ^ |
        - `Number of characters:` from 8 to 256.
    """

    def __init__(
        self,
        label: str = "",
        placeholder: str = "",
        is_hide: bool = False,
        is_ignore: bool = False,
        hint: str = "",
        warning: list[str] = [],  # ruff:ignore[mutable-argument-default]
        is_require: bool = False,
    ) -> None:
        r"""Field of Model for enter password.

        Attention:
            - `Regular expression:` ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
            - `Valid characters:` a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \\ ? [ ] ^ |
            - `Number of characters:` from 8 to 256.

        Agrs:
            label: Text label for a web form field.
            placeholder: Displays prompt text.
            is_hide: Hide field from user.
            is_ignore: If true, the value of this field is not saved in the database.
            hint: An alternative for the `placeholder` parameter.
            warning: Warning information.
            is_require: Required field.
        """
        if Config.DEBUG:
            try:  # ruff:ignore[too-many-statements-in-try-clause]
                if not isinstance(label, str):
                    raise AssertionError("Parameter `label` - Not а `str` type!")
                if not isinstance(is_hide, bool):
                    raise AssertionError("Parameter `is_hide` - Not а `bool` type!")
                if not isinstance(is_ignore, bool):
                    raise AssertionError("Parameter `is_ignore` - Not а `bool` type!")
                if not isinstance(hint, str):
                    raise AssertionError("Parameter `hint` - Not а `str` type!")
                if not isinstance(warning, list):
                    raise AssertionError("Parameter `warning` - Not а `list` type!")
                if not isinstance(placeholder, str):
                    raise AssertionError("Parameter `placeholder` - Not а `str` type!")
                if not isinstance(is_require, bool):
                    raise AssertionError("Parameter `is_require` - Not а `bool` type!")
            except AssertionError as err:
                logger.critical(str(err))
                raise err

        Field.__init__(self, supported_types=(str, type(None)))

        field_core: dict[str, Any] = {
            "id": "",
            "name": "",
            "label": label,
            "input_type": "password",
            "value": None,
            "placeholder": placeholder,
            "is_hide": is_hide,
            "is_ignore": is_ignore,
            "hint": hint,
            "disabled": False,
            "warning": warning,
            "is_require": is_require,
            "errors": [],
            "field_type": "PasswordField",
            "group": "password",
        }

        self.__dict__["field_core"] = FieldCore(**field_core)

__init__(label='', placeholder='', is_hide=False, is_ignore=False, hint='', warning=[], is_require=False)

Field of Model for enter password.

Attention
  • Regular expression: ^[-._!"`'#%&,:;<>=@{}~$()*+/\?[]^|a-zA-Z0-9]{8,256}$
  • Valid characters: a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \ ? [ ] ^ |
  • Number of characters: from 8 to 256.
Agrs

label: Text label for a web form field. placeholder: Displays prompt text. is_hide: Hide field from user. is_ignore: If true, the value of this field is not saved in the database. hint: An alternative for the placeholder parameter. warning: Warning information. is_require: Required field.

Source code in src/ramifice/fields/password_field.py
def __init__(
    self,
    label: str = "",
    placeholder: str = "",
    is_hide: bool = False,
    is_ignore: bool = False,
    hint: str = "",
    warning: list[str] = [],  # ruff:ignore[mutable-argument-default]
    is_require: bool = False,
) -> None:
    r"""Field of Model for enter password.

    Attention:
        - `Regular expression:` ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
        - `Valid characters:` a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \\ ? [ ] ^ |
        - `Number of characters:` from 8 to 256.

    Agrs:
        label: Text label for a web form field.
        placeholder: Displays prompt text.
        is_hide: Hide field from user.
        is_ignore: If true, the value of this field is not saved in the database.
        hint: An alternative for the `placeholder` parameter.
        warning: Warning information.
        is_require: Required field.
    """
    if Config.DEBUG:
        try:  # ruff:ignore[too-many-statements-in-try-clause]
            if not isinstance(label, str):
                raise AssertionError("Parameter `label` - Not а `str` type!")
            if not isinstance(is_hide, bool):
                raise AssertionError("Parameter `is_hide` - Not а `bool` type!")
            if not isinstance(is_ignore, bool):
                raise AssertionError("Parameter `is_ignore` - Not а `bool` type!")
            if not isinstance(hint, str):
                raise AssertionError("Parameter `hint` - Not а `str` type!")
            if not isinstance(warning, list):
                raise AssertionError("Parameter `warning` - Not а `list` type!")
            if not isinstance(placeholder, str):
                raise AssertionError("Parameter `placeholder` - Not а `str` type!")
            if not isinstance(is_require, bool):
                raise AssertionError("Parameter `is_require` - Not а `bool` type!")
        except AssertionError as err:
            logger.critical(str(err))
            raise err

    Field.__init__(self, supported_types=(str, type(None)))

    field_core: dict[str, Any] = {
        "id": "",
        "name": "",
        "label": label,
        "input_type": "password",
        "value": None,
        "placeholder": placeholder,
        "is_hide": is_hide,
        "is_ignore": is_ignore,
        "hint": hint,
        "disabled": False,
        "warning": warning,
        "is_require": is_require,
        "errors": [],
        "field_type": "PasswordField",
        "group": "password",
    }

    self.__dict__["field_core"] = FieldCore(**field_core)