Automattic\WooCommerce\Admin\API\Reports
TimeInterval::rest_validate_between_date_arg()
Validate a "*_between" range argument (an array with 2 date items).
Method of the class: TimeInterval{}
No Hooks.
Return
WP_Error|true|false
.
Usage
$result = TimeInterval::rest_validate_between_date_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_date_arg() TimeInterval::rest validate between date arg code WC 9.6.1
public static function rest_validate_between_date_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 ) || ! rest_parse_date( $value[0] ) || ! rest_parse_date( $value[1] ) ) { return new \WP_Error( 'rest_invalid_param', /* translators: %s: parameter name */ sprintf( __( '%s must contain 2 valid dates.', 'woocommerce' ), $param ) ); } return true; }