Skip to main content
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Uniface Development: Email address validation

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

19 replies

Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Theo,

I would not like to have to identify what I think a valid email address is, I would expect to have an industry/internet limitation of the allowed syntax.

EG. I may only validate the existance of the @ character. But then my rules might need to change to validate that there must be at least one "." on the right side of the @ character. Then my rules migh change to include a list of available TLDs... (.com, .sc, .au) each with their own set of sub rules... (.com.au, .org.au, .co.uk, .co.cn, etc).

Ideally, I want these rules to be defined at an industry/internet level.

Thanks

 


Author: discooctopus (disco@discooctopus.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

discooctopus, sochaz,

Can you take one other try at explaining exactly what validation rules you want on an email adress?

I would like to take a shot at solving this.

Theo.


Author: Theo Neeskens (tneeskens@itblockz.nl)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Uli,

as for your post(s) and my reaction (mainly  about syntax), I have read your post once more, and I admit, I misunderstood it. I'm really sorry for that, my fault.

As for 3GL and regexp in some kind of DLL, please read our discussion about regexp (see related content in my first post in this thread) - you suggested to me the same and I have answered you, that we already have regexp in DLL (of course!) but there are limitations.

Kind regards,
Zdenek


Author: sochaz (zdenek.socha@fullsys.cz)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Zdenek,

looks like you misinterpreted my post:

You can use syntax string if all you want to test is a simple "something@another.location" specification.

For all other things, you have the validate trigger.

About the 30 lines of code:

just spent some 2 hrs browsing the web for "the" eMail-Address validation.
The collection can be found on the "giveaways" page of www.uli-merkel.de/dito
Belive me, the regexes alone span over a couple of lines.
 

The uniface code I prepared is a uniface 8 one and build for speed.
It could have been much smaller.
Using $SPLIT and $REPLACE in Uniface9 drastically reduces the amount of lines.

And in this code there are reusable routines (write once, use many) like:
check if the string is made only of listed characters (defined as you like).

Another option:

Uniface provides the use of a DLL,
so if you find some 3GL (C, c++ preferred) code which evaluates regexes
give me the link and we will have a dITo REGEX in a couple of days.

Success, Uli

P.S. I am not employed by CPWR, so no need for excuses if you critisise the product. I do it as well.


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Iain,

I am not sure, what you want from me... regexp functions or regular expressions themselves? Just to be sure, I mention both.

Regexp functions - the most important is compare, scan (search), replace, split, substring.

As for regular expression, just as Disco writes, I do not want to mention concrete regexp's here, since it is always subject to change. But, just as guideline for what we need, I'll try to write some sort of very short list (limited to validation purposes only):

  • email adress - see my recent post for simple regexp
  • postal (ZIP) code - different for each country, e.g. here in Czech Republic it has 5 digits with optional space, e.g. "[0-9]{3} ?[0-9]{2}"
  • bank account and bank code, IBAN, SWIFT code - but bank accounts and codes, it is again different in different countries
  • product numbers - different for each company
  • product/goods codes - some internations standards, for example intrastat and/or custom purposes, statistics etc.
  • date and time validation - for importing external txt files
  • any other proprietary codes (mainly during import/export of data on B2B level, for example with bank companies)
  • name validation - not only user-name, but company names etc... first letter uppercase, limited to some characters (not the whole ascii), e.g. "[A-Z][a-z]+[a-z0-9]*"
  • phone and fax numbers - most of time, it has 9digits with optional spaces (for example 123 456 789) with optional international code (+420)
  • ... etc...

I believe there are several other situations, which I just did not mention here.

Kind regards,
Zdenek


Author: sochaz (zdenek.socha@fullsys.cz)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Zednek, So, write me the regexp functions you want to validate, and I'll put you a global proc together to do it....


Author: Iain Sharp (i.sharp@pcisystems.co.uk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Uli,

great piece of code. I don't want to flame, but you told, syntax string will do [the job]. But I can't see any use of syntax in your proc code. :-) Anyway, that proc is quite interesing, but as you can see, you have 30line of proc code just to validate (and split) email adress. We need similar validation for many many other things and writing special proc entry for every single validation is not very effective - as long as we talk about 4GL language in the 21st century.

For example, we need to validate product numbers in many different companies, with many different rules. Rules are not complicated, but it can't be achieved by using just Uniface syntax. Yes, there are syntax codes for digits, letters, letter/digit/underscore, but that's far too limited. Most of times, we just need combination of letters, digits and few extra characters (like dot, coma, hypen, underscore).

Sorry for beeing a bit off-topic
Zdenek


Author: sochaz (zdenek.socha@fullsys.cz)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Zdenek,

as I said, it is all about what you call a valid eMail.

Validate an email is a very easy task, even in Uniface 4GL, becaus its all about string handling.

 

*) or do it the split way (divide and rule):

Split what leads and trails "@"
for both sides, split segments by the "." part.

Examine the different segments.

Expl. Each segment must consist only of 1-0,a-z,A-Z,-,_

Expl. right side has to have at least 2 segments
Expl: last segment right side has to be one of "com,eu,il, ...."

*) Or do it the state-machine-way (eat the string):

Just inspect any single character from left to right
 

$position$ = 1
$workchar$ = inspectstring[$position$:1]

while ($workchar$ != "")

   .... do some checks here
  $position$ = $position$ + 1
  $workchar$ = inspectstring[$position$:1]

endwhile

Given a bit more time, I will create a dITo example how to do it. Here is the basic code:

*************************************************************************
entry split_adress ; separate the different segments AND check characters
params
   string p_emailadress : IN
   string p_personlist  : OUT ; before "@" ("ton.blankers")
   string p_hosterlist  : OUT ; after  "@" ("nl·;compuware·;com")
   string p_errorsfound : OUT ; "illegal character 'ä' found"
   numeric p_nerrors    : OUT ;
endparams
variables
   string v_String, v_Char, v_allowedlist
   numeric nATfound
endvariables  
   v_allowedlist = "0·;1·;2·;3·;4·;5·;6·;7·;8·;9·;a·;b·;c·;d·;e·;f·;g·;h·;i·;j·;k·;l·;m·;n·;o·;p·;q·;r·;s·;t·;u·;v·;w·;x·;y·;z·;-·;_"
   p_nErrors = 0
   nATfound = 0
   $1 = 1  ; position counter
   v_Char = p_emailadress[$1:1]
   while (v_char != "")
      selectcase (v_Char)
         case "@"  ; the character "@"
           nATfound = nATfound + 1
           p_personlist = v_String
           v_String = ""
         case "."
           v_string = "%%v_string%%%·;"
         elsecase
           v_string = "%%v_string%%%%%v_Char%%%"
           if ($item(v_Char,v_allowedlist) = "") ; not in List
              p_nErrors  = p_nErrors + 1
              p_errorsfound = "%%p_errorsfound%%%%%^illegal character '%%v_Char%%%'"
           endif
      endselectcase
      $1 = $1 + 1
      v_Char = p_emailadress[$1:1]
   endwhile
   p_hosterlist = v_String
   if (nATfound != 1)
      p_errorsfound = "%%p_errorsfound%%%%%^@ found %%nATfound%%% times"
      p_nErrors = p_nErrors + 1
   endif
end ; split_adress
**********************************************************************************************************

SUccess, Uli

P.S. To all interested in the adress business,
if you know other rules to validate, here is the place to collect this.


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:17 AM UTC

Email address validation

Author: disco@discooctopus.com (discooctopus)

Hi,

Does anyone have a nice way of validating an email address (syntax string, proc code, field syntax properties, etc) in a field with a stringent set of rules?

I did find this... http://uniface.communityzero.com/uniface?go=2222502&content=entry ... but not sure if this type of thing will be considered???

Thanks

 

Hi Uli,

I can't help myself, I have to argue with you. In this case, i.e. validating an e-mail adress, Uniface syntax will NOT do (the job here). E-mail adress is not only about the at-sign ("@") and some points (".") around it.

You can have alphanum and some extra characters (e.g. dot, plus) before at-sign, and very similar string after the at-sign. After very last dot, you should have valid domain (or at least to check, it is 2 or 3 or 4 characters long, which is 99% domains, I believe). As far as I know, this is beyond the ability of Uniface syntax strings. Oh man, how I wish I was wrong!

Of course, you can validate e-mail adress using Uniface 4GL, but it is neither easy nor nice task. There would be a bunch of code to do this.

Just my 2 cents :-)
Zdenek Socha


Author: sochaz (zdenek.socha@fullsys.cz)