Skip to content

Constraint for the number of results a content element on a page object should return #149

Description

@geb-bot

Originally created by Christoph Neuroth.

As an addition to the "required" constraint, we would like to be able to be more specific about the expected number of results. For example specifying "1 or more" is possible with "required: true" and "0 or more" with "required:false", but it's not currently possible to make sure there is exactly 3 results.

Proposed syntax:

static content = {
  a1(times: 0..1)    {...} // optional, but only once
  a2(min: 0, max: 1) {...} // equivalent

  b1(times: 1..1)    {...} // required, but no more than once
  b2(min: 1, max: 1) {...} // equivalent
  b3(times: 1)       {...} // equivalent

  c1(min: 1)         {...} // required, but can return many
  c2(required: true) {...} // equivalent, current syntax

  d1(min: 3, max: 9) {...} // 3 to 9
  d2(times: 3..9)    {...} // equivalent

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions