I've jumped into RegEx without much experience and thought adding a starter set of validations might help others get some basic functionality into their forms more quickly (and save the time I spent Googling and trial and error).
Mandatory Valid Email
By design this rule ensures domain formatting has no spaces, commas, double full stops or end with a full stop.
Email is a tricky one to validate because almost almost anything before the "@" can be valid if it's within quotes. For that reason, this simple rule states:
There must be something before the @
There must be an @
After the @ must follow characters that do not include a comma, full stop or a space
Next must follow at least one group that starts with a full stop before a string of characters excluding a comma, full stop or a space
RegEx =^.+@([^,\.\ ])+(\.([^,\.\ ])+)+$
--
Phone number - Min 10 digits (not mandatory)
Domestic phone numbers in Australia (standard landline or mobile) which inlclude an area code, are a minimum of 10 digits. So making sure a phone number has a minimum of 10 is a sufficient test. Even if users add brackets, spaces, + or dashes it will pass. So people adding international codes or extension numbers won't be penalised. Of course, promotional business numbers may get blocked, such as 130 000, or 911.
RegEx =^(\D*(?:\d\D*){10,})?$
--
Valid Australian Landline or Mobile Phone Number
If you want to get very strict in Australia, you can mandate a strict landline or mobile number format. I doubt it's required though, unless you're sure your audience is domestic only, in which case it might slow down a few spam bots.
Until then, it would make a lot of sense to include your samples as documentation to supplement the existing documentation on validations: http://www.formulate.rocks/validations
If you want to submit a pull request to get this documentation included in the main documentation site, you can do so here (the "gh-pages" branch of the main repository): https://github.com/rhythmagency/formulate/tree/gh-pages
A few handy validation Regular Expressions
I've jumped into RegEx without much experience and thought adding a starter set of validations might help others get some basic functionality into their forms more quickly (and save the time I spent Googling and trial and error).
Mandatory Valid Email
By design this rule ensures domain formatting has no spaces, commas, double full stops or end with a full stop.
Email is a tricky one to validate because almost almost anything before the "@" can be valid if it's within quotes. For that reason, this simple rule states:
RegEx =
^.+@([^,\.\ ])+(\.([^,\.\ ])+)+$
--
Phone number - Min 10 digits (not mandatory)
Domestic phone numbers in Australia (standard landline or mobile) which inlclude an area code, are a minimum of 10 digits. So making sure a phone number has a minimum of 10 is a sufficient test. Even if users add brackets, spaces, + or dashes it will pass. So people adding international codes or extension numbers won't be penalised. Of course, promotional business numbers may get blocked, such as 130 000, or 911.
RegEx =
^(\D*(?:\d\D*){10,})?$
--
Valid Australian Landline or Mobile Phone Number
If you want to get very strict in Australia, you can mandate a strict landline or mobile number format. I doubt it's required though, unless you're sure your audience is domestic only, in which case it might slow down a few spam bots.
RegEx =
^(\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3})?$
Hi Anthony,
Thanks for this!
I actually hope to include a few sample validations with Formulate at some point: https://github.com/rhythmagency/formulate/issues/24
Until then, it would make a lot of sense to include your samples as documentation to supplement the existing documentation on validations: http://www.formulate.rocks/validations
If you want to submit a pull request to get this documentation included in the main documentation site, you can do so here (the "gh-pages" branch of the main repository): https://github.com/rhythmagency/formulate/tree/gh-pages
It's written in markdown. For reference, here's the markdown for the validations documentation I linked to above: https://raw.githubusercontent.com/rhythmagency/formulate/gh-pages/validations.md
Let me know if you have any questions regarding submitting pull requests.
They might prove helpful to folks like me. I'm unlikely to have a chance to incorporate them anytime soon. AE
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.