Automattic\WooCommerce\Admin\RemoteInboxNotifications

TotalPaymentsVolumeProcessor::validate()publicWC 1.0

Validates the rule.

{} It's a 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.

Code of TotalPaymentsVolumeProcessor::validate() WC 7.1.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 ) ) {
		return false;
	}

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

	return true;
}