FieldMaskRule class
字段名掩码规则,通过字段名匹配敏感数据。
适用于 Map 结构的数据,通过字段名列表匹配需要脱敏的字段。 支持嵌套对象和列表项的递归处理。
示例
// 匹配 password、token、secret 字段
final rule = FieldMaskRule(
fieldNames: ['password', 'token', 'secret'],
strategy: MaskStrategy.full,
);
Constructors
-
FieldMaskRule({required List<
String> fieldNames, MaskStrategy strategy = MaskStrategy.full, int? keepCount = 4, String? customMask}) -
创建字段名掩码规则。
const
Properties
- customMask → String?
-
自定义掩码字符串。
finalinherited
-
fieldNames
→ List<
String> -
需要匹配的字段名列表。
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keepCount → int?
-
保留字符数量。
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- strategy → MaskStrategy
-
掩码策略。
finalinherited
Methods
-
apply(
String value, LogMaskingConfig config) → String -
对值应用掩码处理。
override
-
matches(
dynamic key, dynamic value, [LogMaskingConfig? config]) → bool -
判断给定的键值对是否匹配当前规则。
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited