Skip to content

Method Validator Ignores Null Values / Empty Strings #13

@homestar9

Description

@homestar9

While I was updating the documentation, I noticed the method validator ignores empty/null values. This puzzled me because the udf validator does not ignore empty/null values. I always thought the udf and method validators were similar and could be used interchangeably if you required a more complex function that you wanted to break out from the constraints struct.

Should we allow null/empty strings to pass through to the method and let it decide what to do about null values? In 95% of my udf validators I check for a null/empty value and return true, so maybe the method validator is the one doing it correctly? I see arguments for both approaches so I'm not sure what the best way to proceed is, so I would love some feedback/suggestions.

Method Validator:
https://github.com/coldbox-modules/cbvalidation/blob/0a8dbe8355cfbd4e20db90d0c3be9b2f592b6a2f/models/validators/MethodValidator.cfc#L36-L44

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