Adding your own custom data types
This article covers how to extend the masked data types available in your custom_types.ttl
file. If you do not already have a custom_types.ttl
file, follow the steps for getting one found at the bottom of Masking data with custom data types. If you are already using custom data types, download a copy of the custom_types.ttl
file from your organization's ddw-ontologies
dataset.
The easiest way to create a new masked data type in your custom_types.ttl
file is to copy an existing data type and paste it at the bottom of the file to use as the basis for your new type:
Note
If you are unfamiliar with the nomenclature and structure used for .ttl files, see our overview of the custom_types.ttl
file
The triples (or lines of the file) you need to change are:
The name of the data type in the ontology -
hg:masked_us_phone_number a csvw:Datatype;
The title for the menu -
dc:title "Masked US Phone Number" ;
The description -
dc:description "US phone number with area code" ;
- justHow you want it rewritten -
dwo:mask [ a dwo:RegexMask; dwo:matchPattern "([0-9]{3})-([0-9]{3})-([0-9]{4})"; dwo:rewritePattern "XXX-XXX-XXXX"].
)
For this example you do not need to change:
The expected input format -
csvw:format "[0-9]{3}-[0-9]{3}-[0-9]{4}";
Do not change:
The location of the definition-
dwo:isDefinedIn hg: ;
The data type of the output string -
csvw:base dwo:maskedString;
Warning
It is a highly recommended to test your new data type on a test table before applying it to production data. If you inadvertently create an invalid data type, you will need to recreate any table you applied it to.