rest_validate_null_value_from_schema

The timeline below displays how wordpress function rest_validate_null_value_from_schema has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.7

/**
 * Validates a null value based on a schema.
 *
 * @since 5.7.0
 *
 * @param mixed  $value The value to validate.
 * @param string $param The parameter name, used in error messages.
 * @return true|WP_Error
 */
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;
}