WordPress at a glance
function is not described

wc_rest_validate_reports_request_arg() WC 2.6.0

Validate reports request arguments.

No Hooks.

Return

WP_Error|true|false. Nothing.

Usage

wc_rest_validate_reports_request_arg( $value, $request, $param );
$value(mixed) (required)
Value to valdate.
$request(WP_REST_Request) (required)
Request instance.
$param(string) (required)
Param to validate.

Changelog

Since 2.6.0 Introduced.

Code of wc_rest_validate_reports_request_arg() WC 5.3.0

<?php
function wc_rest_validate_reports_request_arg( $value, $request, $param ) {

	$attributes = $request->get_attributes();
	if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
		return true;
	}
	$args = $attributes['args'][ $param ];

	if ( 'string' === $args['type'] && ! is_string( $value ) ) {
		/* translators: 1: param 2: type */
		return new WP_Error( 'woocommerce_rest_invalid_param', sprintf( __( '%1$s is not of type %2$s', 'woocommerce' ), $param, 'string' ) );
	}

	if ( 'date' === $args['format'] ) {
		$regex = '#^\d{4}-\d{2}-\d{2}$#';

		if ( ! preg_match( $regex, $value, $matches ) ) {
			return new WP_Error( 'woocommerce_rest_invalid_date', __( 'The date you provided is invalid.', 'woocommerce' ) );
		}
	}

	return true;
}