rest_validate_null_value_from_schema() WordPress Function

The rest_validate_null_value_from_schema() function is used to check if a given value is of the correct type to be null according to the schema. It is used internally by the WordPress REST API to perform type validation on request data.

rest_validate_null_value_from_schema( mixed $value, string $param ) #

Validates a null value based on a schema.


Parameters

$value

(mixed)(Required)The value to validate.

$param

(string)(Required)The parameter name, used in error messages.


Top ↑

Return

(true|WP_Error)


Top ↑

Source

File: wp-includes/rest-api.php

function rest_validate_null_value_from_schema( $value, $param ) {
	if ( null !== $value ) {
		return new WP_Error(
			'rest_invalid_type',
			/* translators: 1: Parameter, 2: Type name. */
			sprintf( __( '%1$s is not of type %2$s.' ), $param, 'null' ),
			array( 'param' => $param )
		);
	}

	return true;
}


Top ↑

Changelog

Changelog
VersionDescription
5.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.