NAME

GDPR::IAB::TCFv2::Validator::Reason - machine-readable validation-failure codes

SYNOPSIS

use strict;
use warnings;

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

use feature 'say';

say "Code is ", ReasonVendorNotDisclosed,
    ", and it means ", reason_string(ReasonVendorNotDisclosed);
# Output:
# Code is 2, and it means vendor not disclosed

# Lookup by name via the description hashref (auto-quoted bareword).
say ReasonDescription->{ReasonPublisherRestrictionNotAllowed};
# Output:
# publisher restriction: not allowed

DESCRIPTION

Stable, integer-valued reason codes that describe why "validate" in GDPR::IAB::TCFv2::Validator or "validate_all" rejected a TCF consent string. The set mirrors the Reason enum from the Go lib-gdpr/validator package so cross-language tooling can share a single vocabulary.

Each code is also accompanied by a short human-readable string available via "reason_string" (lookup by integer) or "ReasonDescription" (lookup by constant name).

CONSTANTS

All constants are non-negative integers. The values are stable: new codes are appended; existing codes never change.

ReasonNone

Code 0. Successful validation; no failure to report.

ReasonMissingDisclosedVendors

Code 1. The TC string is missing the mandatory disclosed vendors segment (TCF v2.2+ requirement under policy version >= 5).

ReasonVendorNotDisclosed

Code 2. The configured vendor ID is not present in the disclosed vendors segment.

ReasonVendorNotAllowed

Code 3. The vendor is not allowed globally: neither vendor consent nor vendor legitimate interest is granted for any purpose.

ReasonPurposeNotAllowed

Code 4. A required purpose has neither its consent flag nor its legitimate-interest flag set.

ReasonPublisherRestrictionNotAllowed

Code 5. A publisher restriction of type 0 (Not Allowed) is present for a required purpose. Always rejects.

ReasonPublisherRestrictionRequireConsent

Code 6. A publisher restriction of type 1 (Requires Consent) is present for a purpose configured under the legitimate-interest legal basis.

ReasonPublisherRestrictionRequireLegitimateInterest

Code 7. A publisher restriction of type 2 (Requires Legitimate Interest) is present for a purpose configured under the consent legal basis.

ReasonVendorNotAllowedConsent

Code 8. The vendor is not allowed for a specific purpose under the consent legal basis (vendor consent flag and/or purpose consent flag is missing).

ReasonVendorNotAllowedLegitimateInterest

Code 9. The vendor is not allowed for a specific purpose under the legitimate-interest legal basis (vendor LI flag and/or purpose LI flag is missing).

ReasonLegitimateInterestNotPermittedForPurpose

Code 10. The TCF spec forbids the legitimate-interest legal basis for this purpose, regardless of the vendor's signal: Purpose 1 always, and Purposes 3-6 on TcfPolicyVersion >= 4 (TCF v2.2+).

ReasonPolicyVersionTooLow

Code 11. The consent string's TcfPolicyVersion is below the validator's configured min_policy_version.

ReasonDecodeError

Code 12. The consent string could not be decoded (malformed, empty, or unsupported version). Only emitted when the validator is configured to report decode errors as structured failures rather than via croak.

ReasonDescription

Hashref mapping each constant name ("ReasonNone", "ReasonVendorNotAllowed", ...) to its human-readable string. Useful with auto-quoted bareword subscripts:

my $msg = ReasonDescription->{ReasonVendorNotAllowed};

FUNCTIONS

reason_string

my $msg = reason_string($code);

Returns the human-readable description for an integer reason code. Returns "unknown validation failure" for unknown or undefined codes.

SEE ALSO

GDPR::IAB::TCFv2::Validator, GDPR::IAB::TCFv2::Validator::Result.