Skip to content

maxLength validation secretly trims string #134

@bazwilliams

Description

@bazwilliams

The length of the string is trimmed before being checked for length. This means a string "1234 " is reported with a length of 4 passing our validation check and sent onto our server which fails because it has 5 characters.

Whilst ultimately we don't want spaces after our part numbers, the discrepancy between the string stored in the Backbone model (5 chars) and what is reported back from backbone.validation is not ideal. If we trim the text before sending to the server then it will have been generated from a different code path. If we trim the text before validation, then the trim is performed twice.

Turns out this is the case with Length and minLength.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions