rest_validate_null_value_from_schema( mixed $value, string $param ): true|WP_Error

In this article

Validates a null value based on a schema.

Parameters

$valuemixedrequired
The value to validate.
$paramstringrequired
The parameter name, used in error messages.

Return

true|WP_Error

Source

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;
}

Changelog

VersionDescription
5.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.