Sorry, we don't support your browser.  Install a modern browser

Field Cardinality#38

GraphCMS needs the ability to control the numbers of repeated fields and relations. Currently, the only control over cardinality is the “required” checkbox. Ideally, we should be able to model real-world constraints on the number of times any field or relation can repeat, like so (a ‘la regex groups):

  • 0 or 1
  • 0 or more
  • 0 or n
  • n or more
  • n or m
  • 0 or n or m
  • exactly n

For example, just yesterday I was trying to model an app store-like product preview, with optional screenshots. I wanted to constrain cardinality to something like: “This isn’t required (zero is ok), but if there are screenshots, there must be between 3-5 (inclusive)”.

Not only is this a general win for data modeling and preventing input errors, the ability to exert complete control over all aspects of cardinality has huge payoffs for downstream development. I can’t tell you the amount of conditional logic I’ve put into my UX components to work around this.

a year ago
Merged into Field Validations#24
8 months ago