MailPoet\EmailEditor\Validator

Validator::validate_schema_array()publicWC 1.0

Strict validation & sanitization implementation. It only coerces int to float (e.g. 5 to 5.0).

Method of the class: Validator{}

No Hooks.

Return

Mixed.

Usage

$Validator = new Validator();
$Validator->validate_schema_array( $schema, $value, $param_name );
$schema(array) (required)
The array must follow the format, which is returned from Schema::toArray().
$value(mixed) (required)
The value to validate.
$param_name(string)
The parameter name.
Default: 'value'

Validator::validate_schema_array() code WC 9.8.1

public function validate_schema_array( array $schema, $value, string $param_name = 'value' ) {
	$result = $this->validate_and_sanitize_value_from_schema( $value, $schema, $param_name );
	if ( $result instanceof WP_Error ) {
		throw Validation_Exception::create_from_wp_error( $result ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
	}
	return $result;
}