PIIPattern class

Defines a PII detection pattern with its regex, type, and replacement text.

Used by PIIDetector to match and replace PII in strings. Developers can create custom patterns and register them at runtime.

final pattern = PIIPattern(
  type: PIIType.custom,
  regex: RegExp(r'ACCT-\d{10}'),
  replacement: '[ACCOUNT HIDDEN]',
  description: 'Internal account numbers',
);
PIIDetector().addPattern(pattern);

Constructors

PIIPattern({required PIIType type, required RegExp regex, required String replacement, String description = '', bool validator(String match)?})
Creates a PIIPattern with the required fields.
const

Properties

description String
An optional human-readable description of what this pattern matches.
final
hashCode int
The hash code for this object.
no setterinherited
regex RegExp
The regular expression used to match PII.
final
replacement String
The text that replaces matched PII.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type PIIType
The PII type this pattern detects.
final
validator bool Function(String match)?
An optional validation function that receives the matched text and returns true if it is a valid match.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited