NAME

GDPR::IAB::TCFv2::Validator::Failure - structured failure record from the Validator

SYNOPSIS

use GDPR::IAB::TCFv2::Validator::Reason qw<:all>;

my ($validator, $tc_string) = ('...', '...');
my $result = $validator->validate($tc_string);

unless ($result) {
    for my $f ( $result->failures ) {
        warn sprintf "code=%d message=%s\n", $f->code, $f->message;

        if ( $f->code == ReasonVendorNotAllowedConsent ) {
            # machine-readable handling
        }
    }
}

DESCRIPTION

A lightweight value object describing a single failure detected by GDPR::IAB::TCFv2::Validator. Each failure carries a stable integer code from GDPR::IAB::TCFv2::Validator::Reason plus the human-readable message the validator emitted, and any structured context that is relevant to the failure (purpose ID, vendor ID, publisher restriction type, CMP ID).

This is the per-failure analogue of the Go lib-gdpr/validator Result struct: code-driven, machine-actionable, but with a ready-to-display string already attached.

Validator::Failure objects are created by GDPR::IAB::TCFv2::Validator and surfaced via "failures" in GDPR::IAB::TCFv2::Validator::Result; users normally do not construct them directly.

OVERLOADS

Stringification

print "$failure";

Returns "message", so a Failure object drops into any context that expects a reason string.

METHODS

code

my $code = $failure->code;

Integer reason code from GDPR::IAB::TCFv2::Validator::Reason. Use this to switch on the failure type programmatically.

message

my $msg = $failure->message;

Human-readable description of the failure (the same string previously returned by "reasons" in GDPR::IAB::TCFv2::Validator::Result).

purpose_id

my $pid = $failure->purpose_id;

The TCF purpose ID associated with the failure, or undef when the failure is not purpose-specific (e.g. a missing-disclosed-vendors failure or a CMP failure).

vendor_id

my $vid = $failure->vendor_id;

The vendor ID under validation when the failure occurred, or undef when the failure is not vendor-specific.

restriction_type

my $rt = $failure->restriction_type;

The publisher restriction type (0 = NotAllowed, 1 = RequireConsent, 2 = RequireLegitimateInterest) when the failure was caused by a publisher restriction, or undef otherwise.

cmp_id

my $cmp = $failure->cmp_id;

The CMP ID from the consent string when the failure was caused by the CMP-validator rule, or undef otherwise.

CONSTRUCTOR

new

Internal -- Validator::Failure objects are constructed by GDPR::IAB::TCFv2::Validator as it walks its rules, then surfaced via "failures" in GDPR::IAB::TCFv2::Validator::Result.

SEE ALSO

GDPR::IAB::TCFv2::Validator::Reason for the reason-code vocabulary, GDPR::IAB::TCFv2::Validator::Result for the container type returned by "validate" in GDPR::IAB::TCFv2::Validator.