Automattic\WooCommerce\Admin\API\Reports
TimeInterval::rest_validate_between_numeric_arg
Validate a "*_between" range argument (an array with 2 numeric items).
Method of the class: TimeInterval{}
No Hooks.
Returns
WP_Error|true|false.
Usage
$result = TimeInterval::rest_validate_between_numeric_arg( $value, $request, $param );
- $value(mixed) (required)
- Parameter value.
- $request(WP_REST_Request) (required)
- REST Request.
- $param(string) (required)
- Parameter name.
TimeInterval::rest_validate_between_numeric_arg() TimeInterval::rest validate between numeric arg code WC 10.4.3
public static function rest_validate_between_numeric_arg( $value, $request, $param ) {
if ( ! wp_is_numeric_array( $value ) ) {
return new \WP_Error(
'rest_invalid_param',
/* translators: 1: parameter name */
sprintf( __( '%1$s is not a numerically indexed array.', 'woocommerce' ), $param )
);
}
if (
! is_array( $value ) ||
2 !== count( $value ) ||
! is_numeric( $value[0] ) ||
! is_numeric( $value[1] )
) {
return new \WP_Error(
'rest_invalid_param',
/* translators: %s: parameter name */
sprintf( __( '%s must contain 2 numbers.', 'woocommerce' ), $param )
);
}
return true;
}