This is inspired by Neil Gibbons' request for constraints fields in a schema. Neil's issue was two-fold:
- Separate minOccurs from mandatory
- Provide an accessible point in the UI for setting this.
While I like this idea, I think that a limitation here is error messaging: What happens if a user does something that violates the constraint? What if I need a custom constraint (like disallowing certain characters, applying a character count)? Today it's possible to apply that constraint, but I can't add user-friendly messaging to it.
I'd like to propose that we have a new schema type, called "constraint". The Contraints schema would allow me to apply the following kinds of constraints -- with accompanied error messaging:
- minOccurs : n minimum instances of field
- maxOccurs : n maximum instances of field
- minLength : n minimum characters allowed in field
- maxLength : n maximum characters allowed in field
- Mandatory: boolean that indicates that the field must have a value
- Pattern : Regex that indicates what strings are allowed as a value
- Logic [and, or, not()] : Sets the Mandatory flag to true when there are fieldnames matching the right-hand side of the operator (or argument) are present and pass their own constraints
And again, each constraint within the schema has an accompanying error message.
90% of the time, I can get by without this. But the other 10%, I can't use Tridion unless it's got this.