Validates and formats phone numbers in Flatfile using country-specific validation with libphonenumber-js library
libphonenumber-js
library for robust, country-specific validation. The primary use case is to ensure that phone number data ingested into Flatfile is correctly formatted and valid. It can automatically correct and reformat phone numbers into various standard formats (e.g., NATIONAL, INTERNATIONAL, E164) or simply add an error to the record if the number is invalid.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
phoneField | string | Yes | - | The API key (name) of the field containing the phone number to validate |
countryField | string | Yes | - | The API key (name) of the field containing the country code (e.g., ‘US’, ‘GB’) |
sheetSlug | string | No | '**' | The slug of the sheet to apply the validation to. Defaults to all sheets |
autoConvert | boolean | No | true | If true, automatically updates the phone number field with the correctly formatted version |
format | string | No | 'NATIONAL' | The desired output format: ‘NATIONAL’, ‘INTERNATIONAL’, ‘E164’, ‘RFC3966’, or ‘SIGNIFICANT’ |
concurrency | number | No | 10 | Number of records to process concurrently |
debug | boolean | No | false | Enables verbose debug logging in the console |
formatOptions | object | No | - | Additional formatting options for libphonenumber-js library |
phoneField
and countryField
values in the configuration exactly match the field keys in your Sheet template.
countryField
in your data contains valid two-letter ISO 3166-1 alpha-2 country codes (e.g., “US”, “GB”, “DE”).
debug
option to true
in the configuration to see more detailed logging output in your environment’s console, which can help diagnose issues.
sheetSlug: '**'
)autoConvert
is true
(default)libphonenumber-js
countryField
must contain a valid two-letter ISO 3166-1 alpha-2 country codecommit:created
event, processing records in batches