Skip to main content

selectionValidators

selectionValidators

Type: array
Default: []

selectionValidators: [
{type: 'noOrphanSeats'},
{type: 'consecutiveSeats'},
{ type: 'minimumSelectedPlaces', minimum: 4 }
]

Selection validators run every time a seat is selected or deselected. They check whether there are no orphan seats, and/or whether all selected seats are consecutive (meaning: next to each other and in the same category).

If the selection is valid, onSelectionValid is triggered. If not, onSelectionInvalid is triggered.

A typical way to use this is to disable the checkout button on your form and to show a warning when onSelectionInvalid is triggered.

Prevent Orphan Seats

The noOrphanSeats selection validator validates whether or not a selection leaves open single seats, also known as orphan seats.

selectionValidators: [
{ type: 'noOrphanSeats' }
]
Orphan validator

Not all single empty seats are necessarily considered as orphan seats. A single empty seat is considered an orphan seat if there is no other way to select the same number of seats without leaving an empty seat. This rule is designed to make it still possible for ticket buyers to select seats, even when there are just a few groups left, typically at the end of sales.

For example, consider two rows, each with just three available seats left:

Orphan validator

In this scenario, if a ticket buyer needs two seats together, they will have to leave an empty seat beside them. Since there is no alternative way to fulfill the ticket buyer's seating preference without leaving an empty seat, the empty seat created in this situation is not considered an orphan.

Lenient mode

You can make the orphan seats validator less restrictive by passing in mode: 'lenient':

selectionValidators: [
{ type: 'noOrphanSeats', mode: 'lenient' }
]

In lenient mode, single empty seats are not considered orphans if there's no other way than to leave an empty seat in the current "block". Meaning: in the current group of selectable seats that are next to each other:

Orphan validator - Lenient

The default mode is 'strict':

Orphan validator - Strict

Ignoring category boundaries

By default, orphan seat detection identifies potential orphans both at the ends of rows and within rows when adjacent seats belong to different categories. You can change this behavior by passing in ignoreCategories: true; differences in seat categories won't trigger orphan seat detection anymore.

selectionValidators: [
{ type: 'noOrphanSeats', ignoreCategories: true }
]

For instance, take a chart that looks like this without any selection:

Orphan validator - Strict

With ignoreCategories: false (i.e. the default), this selection will trigger an orphan seat:

Orphan validator - Strict

However, with ignoreCategories: true, the same selection will not trigger an orphan seat:

Orphan validator - Strict

Highlight

By default, orphans are highlighted by an exclamation mark, and are colored red. If you prefer this doesn't happen, pass in highlight: false.

selectionValidators: [
{ type: 'noOrphanSeats', highlight: false }
]

Consecutive Seats

The consecutiveSeats selection validator checks for seats that are not in the same row and are not next to each other. It also checks for seats that do not have the same category.

This validator doesn't show errors on the chart, but it triggers the onSelectionInvalid event every time an invalid selection is made (i.e. when the current selection contains non-consecutive seats).

selectionValidators: [
{ type: 'consecutiveSeats' }
]

Minimum Number of Selected Places

The minimumSelectedPlaces selection validator checks if a selection meets the minimum number of places that must be selected.

This validator does not display errors on the chart, but it triggers the onSelectionInvalid event every time an invalid selection is made (i.e. when the total number of selected places is less than the minimum required).

selectionValidators: [
{ type: 'minimumSelectedPlaces', minimum: 4 }
]

minimum

The minimumSelectedPlaces selection validator has a required minimum field, which indicates the minimum number of places that needs to be selected before a selection is considered valid. Table seats are counted as places, and so are places in Areas.