MailPoet\EmailEditor\Validator

Validator::validate_and_sanitize_any_of()privateWC 1.0

Mirrors rest_find_any_matching_schema().

Method of the class: Validator{}

No Hooks.

Return

Mixed|WP_Error.

Usage

// private - for code of main (parent) class only
$result = $this->validate_and_sanitize_any_of( $value, $any_of_schema, $param_name );
$value(mixed) (required)
The value to validate.
$any_of_schema(array) (required)
The schema to validate against.
$param_name(string) (required)
The parameter name.

Validator::validate_and_sanitize_any_of() code WC 9.8.2

private function validate_and_sanitize_any_of( $value, array $any_of_schema, string $param_name ) {
	$errors = array();
	foreach ( $any_of_schema['anyOf'] as $index => $schema ) {
		$result = $this->validate_and_sanitize_value_from_schema( $value, $schema, $param_name );
		if ( ! is_wp_error( $result ) ) {
			return $result;
		}
		$errors[] = array(
			'error_object' => $result,
			'schema'       => $schema,
			'index'        => $index,
		);
	}
	/* @phpstan-ignore-next-line Wrong annotation for parameter in WP. */
	return rest_get_combining_operation_error( $value, $param_name, $errors );
}