Skip to content

"mandatory" and "required" field properties need to be refactored #576

@mvorisek

Description

@mvorisek

See #569 (comment)

Currently they are defined like:

  • mandatory - prevent null
  • required - prevent null and anything that evaluates with empty() to true

Currently there are two major issues:

  • the names are not self explanatory
  • two properties does not cover all use cases (we can not allow nullable non-empty field) and the values are not always valid (when required is set, mandatory can be false and can not be used for checking if the field can be null or not)
  • the currently implementation does not even work like it is defined - see "mandatory" null validation is not working #575

I and @DarkSide666 propose to fix all these issues by refactoring this functionality to these fields:

  • notNull - if true, field can not be set null or saved/exported when null is set by default
  • notEmpty - if true, field can not be empty. Emptines should be evaluated to true when (string)$v === '' or for numerical types if (float)$v === 0.0.

With this proposal strings like (space) are considered non-empty. This is good to not solve multiple functionalities at once and it was so also originally as empty(' ') is evaluated to false. This should be fixed by normalization #577 which should be processed first.

These properties are very commonly used and therefore maximum care need to be provided to them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions