<?php
/**
 * Schema for scan-keys.
 *
 * @package Fast-Events/Schema
 * @since 1.0
 */

declare( strict_types=1 );

/**
 * Return the scan-keys schema.
 *
 * @since 2.4.0 Added entry 7 and 8.
 * @since 2.5.0 Added entry 6.
 *
 * @return array
 */
function fast_events_schema_scan_keys(): array {
	return array(
		'type'                 => 'object',
		'patternProperties'    => array(
			'^.{16}$' => array(
				'type'       => 'object',
				'properties' => array(
					'tickets'     => array(
						'type'      => array( 'string', 'null' ),
						'pattern'   => '^([^,]{3,30}(\,[^,]{3,30})*)*$',
						'maxLength' => 1024,
					),
					'entry'       => array(
						'type' => 'integer',
						'enum' => array( 0, 1, 6, 7, 8, 9 ),
					),
					'location'    => array(
						'type'      => 'string',
						'minLength' => 3,
						'maxLength' => 30,
					),
					'date_format' => array(
						'type'      => 'string',
						'minLength' => 3,
						'maxLength' => 100,
					),
				),
				'required'   => array( 'tickets', 'entry', 'location', 'date_format' ),
			),
		),
		'additionalProperties' => false,
	);
}
