Page MenuHomePhabricator

Provide "minlength" and probably "fixedlength"? parameter to the "field" tag
Closed, DeclinedPublic

Description

A "maxlength" parameter is currently already provided, however I have heaps of use cases where a minimum length would come in handy too, e.g. all sorts of IDs like ISSNs, ISBNs or postal codes, phone numbers etc. I am not sure if a fixed length could be done with just a combination of min and max or if a fixed will be better for this case.

Event Timeline

Kghbln raised the priority of this task from to Needs Triage.
Kghbln updated the task description. (Show Details)
Kghbln subscribed.

Have you already experienced a problem where someone entered a value that was too short for one of these fields? Or are you just worried that it could happen in the future?

Yes, though it is not yet a frequent thing. Currently I use the #len parser function to check the length and provide a warning with other functions after the page was saved. I do this for IBANs.

Alright. Have you considered, or tried, using the "regex" input type from Semantic Forms Inputs? That would let you validate not just the length but also the format of each field.

No, will have to dig into this though there are reports that this one is apparently broken. I'll see if that's the case. :)

I'm declining this - perhaps there's a need for "minlength" and/or "fixedlength" parameters, but the examples provided here (phone number, etc.) seem better handled by the "regexp" input type anyway.