Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whitespace trim form field member #35

Open
lhazlewood opened this issue Jun 9, 2017 · 2 comments
Open

Add whitespace trim form field member #35

lhazlewood opened this issue Jun 9, 2017 · 2 comments

Comments

@lhazlewood
Copy link
Member

lhazlewood commented Jun 9, 2017

A certain class of errors surface when a form field string value has leading or trailing whitespace (or both) or is the empty string. It would be ideal if the spec allowed content authors to eliminate these problems and even take a default position to do so.

This issue is a proposal to add a form field member named trim that is a string that may have one of 5 possible values: leading, trailing both, tonull and none with the following semantics:

  • leading: remove any leading whitespace in the field value before further evaluation
  • trailing: remove any trailing whitespace in the field value before further evaluation
  • both: remove any leading and trailing whitespace in the field value before further evaluation.
  • tonull: remove any leading and trailing whitespace. If the resulting string is the empty string, replace the value with null.
  • none: don't modify the field value string at all before further evaluation.

This field MUST be evaluated before evaluating the value against any potentially specified pattern field.

This field would only be evaluated if the field type is string or a string derivative type (like date, time, duration, etc).

If the field type is string (or a derived string type), and a trim member is not defined, then Ion parsers MUST assume a behavior of trim equal to tonull. This default is chosen as it is assumed that the majority of data processing systems do not want any leading or trailing white space or the empty string for data.

Is this a welcome addition? A negative one? Thoughts and opinions welcome.

cc @dogeared @nbarbettini @niklase @fosrias @smizell

@nbarbettini
Copy link
Contributor

Interesting. I could see tonull being useful to be more explicit about how empty strings should behave.

To play devil's advocate: why should this be the concern of ION?

@niklase
Copy link

niklase commented Jul 6, 2017

I suppose the field MUST be evaluated before maxlength and minlength too? And if any other string validations will be introduced in the future they will always be applied after trim.

What about options?

"When an options member is present and the form field type does not equal set or array, any form field value specified MUST equal one of the values found within the Option array." - the value should equal the option after trim had been applied?

I agree trim can be useful and it would be good if it can be expressed in some kind of validation lifecycle/process where all rules to be performed on a string value should be applied after the trim has been applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants