Automattic\WooCommerce\Internal\Abilities

AbilitiesTracking::get_validation_error │ private static │ WC 1.0

Get the error a validation filter result stands for, matching how WP_Ability treats it.

Method of the class: AbilitiesTracking{}

No Hooks.

Returns

WP_Error|null. The error, or null when the value is valid.

Usage

$result = AbilitiesTracking::get_validation_error( $is_valid, $default_code ): ?WP_Error;
$is_valid(mixed) (required)
The filtered validation result.
$default_code(string) (required)
Error code to use when the result is false.

AbilitiesTracking::get_validation_error() code WC 11.3.0

private static function get_validation_error( $is_valid, string $default_code ): ?WP_Error {
	if ( false === $is_valid ) {
		return new WP_Error( $default_code );
	}
	return is_wp_error( $is_valid ) && $is_valid->has_errors() ? $is_valid : null;
}