Definition
The phone transformer can anonymize an existing phone number or completely generate a new one. There are two phone number transformers that differ by type and the configurations that are available to customize the transformer. This transformer specifically takes an integer value and returns an integer value. The Phone (string) transformer takes in a string value, returns a string and has more configurations available.
By default, the phone (integer) transformer generates a random 10 digit phone number.
For example, the following input value:
7829828714
Would produce the following ouput value:
5698437232
You can see we generated a new phone integer value that can be used as an integer phone number. Also, note that we don't include hyphens in this transformer since the output type is an integer
.
Phone numbers also vary in length with some international phone numbers reaching up to 15 digits in length. You can set this transformer to respect the length of the input value if you're working with phone numbers longer than 10 digits in length.
Configurations
Depending on your validations, you may want to configure the output phone number. As we discussed above, some phone numbers may be longer than the default 10 digits in length. The phone number (integer) transformer has the following configurations:
Name | Description | Default | Example Input | Example Output |
---|---|---|---|---|
PreserveLength | Preserve Length will ensure that the output phone number is the same length as the input phone number. | false | 892387243786243 | 290374867526392 |
Examples
There are several ways you can mix-and-match configurations to get different potential phone number formats. Here are some possible combinations:
PreserveLength | Example Input | Example Output |
---|---|---|
false | 2890923784 | 5209273239 |
true | 839304957362 | 916395745371 |