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

Ability to express common constraints without XPath #2281

Open
ebruchez opened this Issue Jul 1, 2015 · 8 comments

Comments

Projects
None yet
1 participant
@ebruchez
Copy link
Collaborator

ebruchez commented Jul 1, 2015

#2242 introduces min/max length via XPath functions:

xxf:max-length(10)
xxf:min-length(5)

The UI then roundtrips to the user-friendly UI by parsing a closed set of XPath expressions.

There is also a mechanism whereby such constraints are stored as MIPs, making them available to the UI when possible.

This issue expands the idea to a larger set of validations, including:

  • for all types
    • is/is not (equality), with a constant or a dynamic expression
  • for string and derived types (email)
    • min/max number of characters (#2242)
    • exact number of characters
    • blank/not blank
    • matches/doesn't match regexp
    • contains/does not contain
    • P2: min/max/range/exact number of words
  • for numbers
    • min/max/range of the value
    • min/max/range number of digits
    • max number of fractional digits ("digits-after-decimal"), see also XML Schema's fractionDigits (#2491)
    • less than
    • less than or equal to
    • greater than
    • greater than or equal to
    • is/is not in the range (including/exluding)
    • positive-or-zero (#2488)
    • positive (#2490)
    • negative-or-zero (#2490)
    • negative (#2490)
  • for dates
    • must/must not be before/after date
    • is/is not in the range (including/exluding)

UI must not show validations which don't make sense for the current type (but if present leave them), which means we
need a list of types supported for each validation.

See also the XML Schema facets:

  • length
  • minLength
  • maxLength
  • pattern
  • enumeration
  • whiteSpace
  • maxInclusive
  • maxExclusive
  • minExclusive
  • minInclusive
  • totalDigits
  • fractionDigits

See also #1112 and #2242.

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Jan 14, 2016

It would be good if specific constraints were only listed for types to which they can apply. For example, fraction-digits doesn't make sense for a string or an integer.

Now if the user changes the datatype, what should happen to the constraint? It should not be automatically removed, but it should probably be marked with a warning.

ebruchez added a commit that referenced this issue Jan 15, 2016

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 18, 2018

We have more validation suggestions from customer. They fall in different categories.

Some could be implemented via regex. For example:

  • only alphanumeric characters
  • no whitespace
  • letters only
  • letters and '.' character only
  • all uppercase ASCII letters

Maybe we could have a general mechanism to add a collection of regex validations? What would it take?

  • the regular expression
  • Form Builder localized name
  • maybe: default localized error message
  • Q: Where would those be stored? Properties?

Some need more complex logic better implemented in native code:

  • min/max/exact/between number of words
  • postal code (Canada)
  • telephone # (US)
  • credit card #
  • IPv4 address
  • minimum length of "x" after removal of all HTML tags
@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

How would such a collection of regexp be stored? There are at least two easy ways:

  1. Store them only in the form definition being edited.
  2. Use properties.

Option 1 prevents reuse between form definitions.

Option 2 lacks a UI and makes the feature much harder to use.

Like with #3120, we can suggest creating a special singleton form for creating and maintaining the library of validations. Orbeon Forms could come with a predefined collection of such validations, and form authors could extend this collection.

Like for section templates:

  • There could be a global validation library, as well as one per app.
  • Form Builder would load/reload the alongside the toolbox.
  • At publish time, we can consider copying the validations to the published form definition.

The format in the form definition is TBD. Like for dynamic labels, we might have to move to nested elements within binds, for example:

<xf:bind ...>
    <fr:validation name="some-validation-id"/>
</xf:bind>
@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

Available validations would appear in the Control Settings's Validation tab.

Should the toolbox show something? There should be a shortcut to add/update validations.

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

Here is how the UI could look like.

custom-regex

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

Q: Should the library be limited to regexes, or could it also support custom validations? For example, that could be done by calling native code. The form author would provide an XPath expression and namespace to access Java code.

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

We also would like to have 4 levels, ideally, instead of just 2 for section templates right now:

  • Orbeon: built-in (stored in resources)
  • Global: all apps/forms (stored in database)
  • App: all forms in this app (stored in database)
  • P2: Form: only this form

It would be nice to be able to copy/paste/move between levels.

@ebruchez

This comment has been minimized.

Copy link
Collaborator

ebruchez commented Sep 19, 2018

More questions:

  • Q: What happens if a validation is removed from the library and is in use?
  • Q: How do we embed the UI in Form Builder? Copy/paste? XBL component?
    • The idea of designing it with Form Builder was to be quicker, and it might also be nice to have a ccess to the editor outside of Form Builder. But when in Form Builder, an iframe or opening another tab would be ugly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment