Skip to content

BaseBone.isInvalid() broken and incomplete #776

@phorward

Description

@phorward

The isInvald() respectively vfunc-parameter to BaseBone is incomplete and broken.
This is what I wanted to achieve:

    roles = SelectBone(
        descr=i18n.translate("viur.user.bone.roles", defaultText="Roles"),
        values=conf["viur.user.roles"],
        required=True,
        multiple=True,
        vfunc=lambda values:
            i18n.translate(
                "user.bone.roles.invalid",
                defaultText="Invalid role setting: 'custom' can only be set alone.")
            if "custom" in values and len(values) > 1 else None,
        defaultValue=list(conf["viur.user.roles"].keys())[0],
    )

There are multiple problems here:

  1. vfunc/isInvalid() is generally not implemented for SelectBone
  2. The vfunc/isInvalid()-function in StringBone is implemented on single values only
  3. In this case, I want to verify the complete bone value and reject, if it contains "custom" as the role name, as "custom" may only be used separately as a special role. It's impossible to fix this.

That's all for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: HighAfter critical issues are fixed, these should be dealt with before any further issues.bug(fix)Something isn't working or address a specific issue or vulnerabilityhelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions