Tribe__Validate::options_multi()

Validates fields that have multiple options (checkbox list, etc.) by making sure the value is part of the options array.


Source

File: src/Tribe/Validate.php

		public function options_multi() {
			// if we are here it cannot be empty
			if ( empty( $this->value ) ) {
				$this->result->valid = false;
				$this->result->error = sprintf( esc_html__( "%s must have a value that's part of its options.", 'tribe-common' ), $this->label );

				return;
			}

			$this->value = is_array( $this->value ) ? $this->value : array( $this->value );

			foreach ( $this->value as $val ) {
				if ( array_key_exists( $val, $this->field['options'] ) ) {
					$this->value         = ( $this->value === 0 ) ? false : $this->value;
					$this->result->valid = true;
				} else {
					$this->result->valid = false;
					$this->result->error = sprintf( esc_html__( "%s must have a value that's part of its options.", 'tribe-common' ), $this->label );
				}
			}
		}