rest_validate_integer_value_from_schema

函数


rest_validate_integer_value_from_schema ( $value, $args, $param )
参数
  • (mixed)
    $value
    The value to validate.
    Required:
  • (array)
    $args
    Schema array to use for validation.
    Required:
  • (string)
    $param
    The parameter name, used in error messages.
    Required:
返回值
  • (true|WP_Error)
定义位置
  • wp-includes/rest-api.php
    , line 2654
引入
5.7.0
弃用

Validates an integer value based on a schema.

function rest_validate_integer_value_from_schema( $value, $args, $param ) {
	$is_valid_number = rest_validate_number_value_from_schema( $value, $args, $param );
	if ( is_wp_error( $is_valid_number ) ) {
		return $is_valid_number;
	}

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

	return true;
}