Automattic\WooCommerce\Admin\RemoteInboxNotifications

OptionRuleProcessor::validate()publicWC 1.0

Validates the rule.

Method of the class: OptionRuleProcessor{}

No Hooks.

Return

true|false. Pass/fail.

Usage

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

OptionRuleProcessor::validate() code WC 7.1.0

public function validate( $rule ) {
	if ( ! isset( $rule->option_name ) ) {
		return false;
	}

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

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

	if ( isset( $rule->transformers ) && is_array( $rule->transformers ) ) {
		foreach ( $rule->transformers as $transform_args ) {
			$transformer = TransformerService::create_transformer( $transform_args->use );
			if ( ! $transformer->validate( $transform_args->arguments ) ) {
				return false;
			}
		}
	}

	return true;
}