🤓Xplan Hint: Validate data with Regex
Did you know you can add data validations to text fields?
Regular Expressions, often shortened to Regex, are incredibly powerful sequences of characters that define a search pattern. When used for data validation, they act like a strict quality controller for your text fields! You can use Regex to enforce specific formats, significantly improving the accuracy and consistency of your data.
Why Use Regex for Data Validation?
Regex is invaluable for:
- Enforcing Data Formats: Ensure that information entered into text fields (like email addresses, phone numbers, or ABNs) strictly conforms to a predefined structure.
- Improving Data Quality: Drastically reduce errors and inconsistencies, making your data more reliable for reporting and analysis.
- Automating Checks: Automatically prevent entries that don't meet your specified criteria, saving you manual correction time.
How Does it Work?
Data validation rules apply a Regex pattern to a string field to check if the field's content matches the specified pattern.
Here are some Regex patterns you can use for validating data:
- Validating a 4-Digit Postcode:
- Pattern:
^\d{4}$
- Use Case: Validate a 'Postcode' field to ensure it's exactly four digits (e.g., 4000).
- Explanation: ^ (start of string), \d matches any digit (0-9), {4} specifies exactly four occurrences, $ (end of string).
- Validating an Australian Business Number (ABN - 11 digits):
- Pattern:
^\d{11}$
- Use Case: Ensure an 'ABN' field contains exactly 11 digits (e.g., 12345678901).
- Explanation: ^ (start of string), \d{11} (exactly 11 digits), $ (end of string).
- Validating an Email Address:
- Pattern:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
- Use Case: Apply this to the Contact|Detail field to ensure entries are valid email formats (e.g., name@domain.com).
- Explanation: This pattern checks for a sequence of alphanumeric characters, periods, underscores, percent signs, pluses, or hyphens, followed by an '@' symbol, then another sequence for the domain, a literal dot \., and finally at least two letters for the top-level domain. The ^ signifies the start of the string, and $ signifies the end, ensuring the entire string matches the pattern.
- Validating an Australian Mobile Phone Number:
- Pattern:
^(04)\d{8}$
- Use Case: Ensure a 'Mobile Number' field only accepts standard 10-digit Australian mobile numbers starting with '04' (e.g., 0412345678).
- Explanation: ^ (start of string), (04) (must start with "04"), \d{8} (followed by exactly 8 digits), $ (end of string).
You may have noticed that mobile number and email address are entered into the same field Contact| Detail. This field is used for all number and address inputs in the contact group, eg home phone, sms email, home/work/other email. Good news, you can combine Regex validations to get the desired result.
-
- Pattern:
^(?:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}|(04)\d{8})$
- Use Case: This will accept values for both the email and mobile numbers as above. You may need to expand this further if you are capturing more types of data.
- Pattern:
Practical Application:
Let's build validation for the contact group where you have email, mobiles and land lines.
Step 1: Summarise examples of the data you want to validate. Ensure your format is consistent.
|
Mobile |
Land Line |
user@gmail.com |
0412 345 678 |
07 3123 4567 |
user@gmail.com.au |
0444 444 444 |
03 2654 4568 |
user.name.123@domain.com |
0498 765 432 |
02 5287 4658 |
user.name.123@domain.com.au |
Step 2: Use AI to generate the Regex code
Step 3: Copy the code provided
Step 4: In Xplan field definitions, go to the Contact group and Detail field
Step 5: Paste your validation code, enter your fail message
Step 6: Test, test and test some more. Ensure you check values that should AND shouldn’t pass. Use the Test value field and Test button.
You will get one of the following messages:
Step 7: Once all your positive and negative tests have passed hit Save.
Benefits you'll see
- Higher Data Accuracy: Get cleaner, more reliable data from the moment it's entered.
- Reduced Manual Effort: Spend less time correcting formatting mistakes.
- Consistent Reporting: Build reports with confidence, knowing your underlying data is consistent.
By leveraging these Regex patterns, you can significantly enhance the data integrity within Xplan!
1 Reply
- rainier.reyes
Advisely Team
This is excellent stuff andrew.wilson.0 – you dropped this: 👑
Welcome to the Advisely forums!
This is where financial advice professionals from all walks of life come together to share knowledge, swap ideas, solve problems, and talk all things growth and efficiency.
Here are some tips when posting in the forums:
- Be respectful and courteous to fellow members
- If a reply helped you, mark it as a solution so other users can find it easily
- Take a moment to read through our Community Guidelines
- For Xplan support issues, it's best to raise a ticket in Iress Connect first. You can also search the discussions for posts about the same issue first before starting a new thread.
- Keep an eye out for our 'Ask me anything (AMA)' threads – these are live text-based Q&As with industry and Xplan experts during a set period of time. Find out when the next one is happening here.
- Don’t be shy! You don’t need to be an expert to help someone out. Many users are looking for practical advice, shared experiences, or just a fresh perspective
- Introduce yourself and meet other members here!
We’re glad you’re here – see you around! 😁
Recent Discussions
Adding attachment icon to Client Portal Messages
Hi Team Please can you consider adding an "attachment" icon like a paperclip to file notes sent to clients via the client portal that have an attachment to them? At the moment, and particularly i...sharyn.evans820 hours agoActive Interactor16Views0likes1CommentLifestyle Assets in Client Portal Fact Find
Hi Team, We've just moved from a 3rd party platform that we used for capturing online fact finds, over to the integrated client portal fact find in Xplan. What we're saddened to see is that current...sharyn.evans83 days agoActive Interactor28Views1like3CommentsWhy Financial Advice Accountability Legislation Needs to Change Now
After my article in the IFA on CSLR and the accountability gap we currently see in Australian financial advice, I have had a number of people ask what specific legislation needs to change to tighten ...tonybeaven4 days agoNetwork Navigator9Views0likes0Comments