Skip to Main Content

Email Address Validation is not validating (DOR, Groovy Validation)

Muneeb AhmedMay 11 2022 — edited May 11 2022

Asalam Alaikum (Greetings to reader)!
I am having issue while trying Groovy Validation in DOR for validate Email Address. I also done some R&D, and found multiple threads regarding this are:

  1. https://docs.oracle.com/en/cloud/saas/sales/22a/oasal/groovy-support-for-email-address-format-validation.html#s20073309
  2. https://docs.oracle.com/en/cloud/saas/applications-common/21d/oacex/groovy-scripts.html (Section: Adding Validations to Fields)
  3. https://blogs.oracle.com/fadevrel/post/common-regular-expression-patterns
    But its still providing error when it comes to save DOR. Also tried multiple REGEX validation, which works on groovy console, but not in DOR.
    -------------------------------------------------------------
    ^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$
    ([a-z]+(\.)?[a-z0-9]+)@([a-z]+)\.{1}([a-z]{2,8})
    /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2}))$/
    /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
    ------
    def emailStr = "someone@someplace.com"
    def regexStr = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
    if (emailStr.matches(regexStr)){
    // If we arrive here then the emailStr is a correctly formatted email string
    } else {
    // If we arrive here then the email address is not correctly formatted and needs to be handled somehow.
    }
    ------
    ([a-zA-Z]+)(\.)?(_)?([a-zA-Z0-9]+)\@{1}([a-zA-Z]+)\.([a-zA-Z0-9]){2,8}
    [a-zA-Z0-9]+\@[a-zA-Z0-9]+\.[a-zA-Z0-9]{2,4}
    /[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})/
    ------
    def emailStr = "someone@someplace.com"
    def regexStr = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
    if (emailStr.matches(regexStr)){
    return true
    }
    ------
    /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
    FlexSeg?.companyEmailAdd.toString() == null || FlexSeg?.companyEmailAdd.toString() ==~ /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/
    -------------------------------------------------------------
    These regex are validating on groovy console, but not with application. Can any one suggest anything I can do to resolve this issue.
    Thank you,
    Regards,
This post has been answered by Muneeb Ahmed on May 30 2022
Jump to Answer
Comments
Post Details
Added on May 11 2022
1 comment
80 views