Built-in Presets/API
MaskIO provides predefined common masking rules and core API: maskText
and maskObject
.
API
API | Description | Version |
---|---|---|
maskText | String masking processor | |
maskObject | Object/Array/Array-object masking processor |
maskText Parameters
maskText: (text: string, config: MaskIoConfig, defaultConfig?: MaskIoConfig)
text
:Required
Input string to be maskedconfig
:Required
Masking configuration (presets or custom rules)defaultConfig
:Optional
Fallback masking configuration (presets or custom rules)
maskObject Parameters
maskObject: (obj: Record<string, any> | any[], config: Record<string, MaskIoConfig | FieldHandler>)
obj
:Required
Object or array to be maskedconfig
:Required
Masking configuration mapping (keys as paths, values as configs or field handlers)
Preset Rules
Preset Name | Description |
---|---|
all | All mask Replaces the entire string with mask characters. |
bankCard | Bank card Displays the last four digits of the card number, masks preceding digits. |
idCard | ID card number Displays the first 3 digits and last 2-4 digits , with other parts replaced by mask characters. |
userName | Name Displays the last character of the name. |
email | Email Preserves the first two characters and domain suffix, masks other parts. Applies full masking if no match is found. |
phone | Phone number Applies region-specific masking patterns while preserving certain digits. |
landline | Landline number Displays area code and last two digits by default, shows last two digits for other formats. |
amount | Monetary amount Full masking. |
verification | Verification code Full masking. |
address | Address Full masking. |
ip | IP address Displays the first three segments , masks the last segment. |
url | URL Preserves domain and path, masks query parameters. |
licensePlate | License plate Displays the first two characters , masks subsequent parts. |