Automattic\WooCommerce\Admin\RemoteInboxNotifications

TotalPaymentsVolumeProcessor::validate()publicWC 1.0

Validates the rule.

Method of the class: TotalPaymentsVolumeProcessor{}

No Hooks.

Return

true|false. Pass/fail.

Usage

$TotalPaymentsVolumeProcessor = new TotalPaymentsVolumeProcessor();
$TotalPaymentsVolumeProcessor->validate( $rule );
$rule(object) (required)
The rule to validate.

TotalPaymentsVolumeProcessor::validate() code WC 8.7.0

public function validate( $rule ) {
	$allowed_timeframes = array(
		'last_week',
		'last_month',
		'last_quarter',
		'last_6_months',
		'last_year',
	);

	if ( ! isset( $rule->timeframe ) || ! in_array( $rule->timeframe, $allowed_timeframes, true ) ) {
		return false;
	}

	if ( ! isset( $rule->value ) || ! is_numeric( $rule->value ) ) {
		return false;
	}

	if ( ! isset( $rule->operation ) ) {
		return false;
	}

	return true;
}