Sharing of useful functions to support contact data validation
I've found myself using a few functions on a regular basis so thought I'd share them on here in case they are of benefit to anyone else.
The attached .dmx file contains the following functions:
- Free from PCI info (checks an input does not contain 16-digit numbers either together or separated by hyphens or spaces every 4th character)
- Valid Country (this is a simple function that checks the input country matches a small list of 'valid' values) in practice you may be better swapping this for a lookup against a larger list.
- Valid Email Format (or null) - a subtle edit to the default email format checker which permits null values as valid
- Valid Phone Format (or null) - a subtle edit to the default international phone format checker which permits null values as valid
- Valid Name Casing Sub-function (Surname Case Correction) - Standardises casing for surnames, including handling of: Scottish names (e.g. McNeal and MacAllister), Irish names (e.g. O'Hara) and Double-Barrel names (e.g. Smith-Jones) as well as any with 1st and 3rd chars capitalised on input e.g. "DeFazio")
- Valid Name Casing - Evaluates if Name data is standardised using proper casing (e.g. "McDonald" is deemed VALID, whereas "Mcdonald" is deemed INVALID) by comparing the input value to the 'standard form' using the above function.
- Valid Name (does not contain invalid characters) - Checks name values for invalid characters (i.e. anything other than letters, full stop, hyphen and apostrophe)
Feel free to use as you like and let me know if you have any ideas for improvement, other functions you've built with respect to evaluation and cleansing of contact data.