👉 Maker of the Month Challenge November - Microflow Validation

1
Happy November!   We’re excited to announce the Maker of the Month challenge of November. What is the challenge you might wonder? We'll challenge you with a new challenge based on the new release every month, the perfect opportunity to test and to show off your Mendix skills. Whoever provides the microflow with the best elaboration, receives a free fancy Maker of the Month t-shirt and a ‘Maker of the Month’ badge on your developer's profile.      Challenge   You are building an app's registration process; when users fill in the registration fields and submit their registration, you want to validate if that information is correct and valid to make sure you capture the right information.  ​​ You are asked to build a microflow that validates the email address field used during the registration, but by only using string handling functions. Meaning, you are not allowed to use any regular expressions. ​​ Share a screenshot of your microflow and elaborate on how your code works. Please note that you may not edit your post after submitting your answer.   Good luck! 💪
asked
12 answers
20

Email != Empty

Find @ and contain only 1

Split Local & Domain Part 

Check Illegal characters and Local < 64

Find Dot

Enjoy !

answered
12

Checking an email for validity regarding the specifications for valid addresses is a nightmare. In almost all cases where people try to implement this they are too strict and prevent users with VALID emails address to register.

 

Simply let the user enter the address twice and check that it contains an ‘@’ so a user at least tried to enter an email.

answered
7

- check @ character
- check if only one at-sign is present
- Split string based on @ char i.e local part and domain part of address
- Retrieve LocalPart and DomainPart from List 
- Check if the DomainPart contains dot 
- Split DomainPart list based on dot to check if dot is not the first or last character
- Check the value of DomainPart after dot, should have length either 2 or 3

answered
4

- Count the number of '@' characters - it should be one.

- Check the Domain and Local address lengths - the local is limited to 64 characters.

- Check that the address ends with a non '.' character, but the Domain must contain a minimum of one '.'

- Check for illegal characters "(),:;<>@[\]

answered
4

Since Mendix is aiming to be a Low Code platform, I would go to the Sprinter / Forurm / Ideas and post an Idea to get an Appstore component that can provide this functionality.
Any Mendix app requiring users from outside the organization you build the app for need this functionality.
This answer probably does not make me Maker of the Month, only hoping that the Idea is going to be picked up, In some months from now, I will have the shortest answer :-)

This answer is intended to make everyone think different (I do like the maker of the month challenge and it is great to see all answers being posted), very often I see people jump into coding on low code, sharing a problem ahead in the Forum Idea can help to make the Mendix product better. If an Idea is implemented, we can refactor complex code to just calling a function (microflow/nanoflow/java) from an appstore module to do this.

answered
4

Hello,

There are many ways to perform e-mail validation.  The exact rules for validation are complex.  You have to read a couple of RFC documents and try to implement them.

The first question you should ask: do I need to re-invent the wheel or has this already been implemented before.

Another question is how to implement the validation.  Is a Microflow the best tool ? Microflows are supposed to be easy to understand.  You can discuss the logic of a Microflow with a business user.  Should we discuss e-mail validation with a business user ? I do not think so.

You may find different e-mail validators written in Java.  The native package javax.mail.internet contains a class InternetAddress with a method validate().  It implements most of the rules defined by the RFC’s.  But it is not perfect.

It is easy to create a Java action that implements this method.  Just read the docs, set-up Eclipse and add a few line to the auto-generated code for the action:

 

The validate () method throws an error in case the supplied string is not a valid e-mail.

In my demo application I have an entity Customer with a property Email.

I have used the new “on change” event that is triggered on each character input.

The Microflow is very simpel.  If the field is empty we consider this as “no-error”.  When the field contains text we call the Java action.  I have added a custom error handler that shows a message to the user.

When running the application this results in

Above solution is easy to implement, easy to understand and works better than many do-it-yourself validations.

However it is not good enough.  Above validations are only looking at the syntax.  But there is more to consider: does the mailbox exist ? Is it a dispostable e-mail address ? Is the mailbox full ?

If you want a high quality customer database with valid e-mail addresses you have to go at least one step further.

Many on-line companies offer e-mail validation services.  Typically you call a REST API, supply the e-mail address and they will perform a bunch of quality tests.  The return value of the REST call give you the answer.

I picked (at random) one of the service providers that have a “free” API (free during test – then you have to pay).  So I used MailerCheck. (I’m not saying they are good are bad – it is just for showing the concept).  The API is documented at https://www.mailercheck.com/api/email-endpoints#single-email-verification.

You need to create an account and a free API key.

Calling the API and waiting for the reply takes a couple of seconds (they try make a SMTP connection to the target server).  So you cannot call this validation at every keystroke.  I called it when leaving the e-mail field.

The Microflow calls the REST API.

The response is a simple JSON structure with only one property

I created an import mapping to handle the response:

The REST call uses this import mapping

In the flow we test on the property status.  The list of possible values are

The REST call takes a few seconds to execute.  The user must be aware of this.

I decided to show a progress message.  This is configured in the settings of the microflow call

As a test I inserted a typo in my real mail address (wim.stevens@mobilit.fgov.be) → wim.stevens@mibilit.fgov.be.

For the Java validator this is a valid e-mail address.

When leaving the field:

 

And after a few seconds

Is this good enough ? Not yet.

After this validation you should send an e-mail to the validated address with some unique url in the body.  The recipient should click on the link to prove that he has received the mail.  I have not implemented this extra step.

So, this is perhaps not the answer expected by the challenge.  But I’m convinced it is a good approach in e-mail validation.

Regards

 

Wim

 

answered
2

I really prefer validating email addresses via activation mail. But for rudimentary checking I would propose this solution as it guarantees that all wrong parts are found before showing the validation message:

answered
2

Hi Team, 

As per my below screenshot, I have an entity called Registration with Email as a attribute.

  1. First, This microflow checks whether the Email is empty or not. If it is empty, throwing the error message to the user 
  2. Then, It again checks the email for the exact format. It validates whether the email has @ letter in it. If not  throwing the error message to the user.

Thanks Team

answered
2

Hi,

I have an Account object, which contains Email attribute. During save process of registration, I have called the following sub microflow activity for Email address validation.

Regards,

Srilatha

answered
2

My check has a few steps:

  1. check if it contains a @
  2. check if it contains max 1 @
  3. check if it contains a dot (.)
  4. check the max overall length
  5. check the max length before the @
  6. check the max length after the @
  7. check if it contains a dot after the @
  8. and then check for every character in the emailaddress if it is legal (a letter, digit or one of the allowed characters

 

if it fits all checks above the result is a boolean true else a boolean false.

 

 

answered
2

Hey Team Mendix!

I did the following checks: 

  • Field is not empty
  • contains @ character
  • contains only 1 @ character
  • local part cannot be empty
  • Domain part cannot be empty
  • Domain part should contain at least one .
  • Emailadress cannot end with a .

 

If the input fails the one of the checks, it will return a validation message about what's wrong or missing.

 

answered
1

Check minimum valid length of an Email.

If whether email has @ character.

Check whether Dot is present, and that too minimum 1 character after @.

Check whether Dot is not the last character and dots are not repeated.

 

answered