New Posts New Posts RSS Feed: Email Validation
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Email Validation

 Post Reply Post Reply
Author
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Topic: Email Validation
    Posted: 18-Oct-2007 at 3:51pm
Currently, the NamedRegexPattern.Email only allows uppercase letters. It has been updated to allow lowercase letters as well. This fix will be available in the Oct. 29 release.
 
Workarounds:
  1. In your app, enter an uppercase email, e.g. ANY@GMAIL.COM.
  2. Override the email property to convert values to uppercase:

    public override string PersonalEmail {

      get { return base.PersonalEmail.ToUpper(); }

      set { base.PersonalEmail = value.ToUpper(); }

    }
  1. Create a new (corrected) email pattern and pass this into the RegexVerifier:

    #region Verification

 

    /// <summary>Get Verifiers.</summary>

    /// <param name="pVerifierProviderContext">Context in which these Verifiers are retrieved.</param>

    /// <returns>The verifiers.</returns>

    [VerifierProvider]

    public static IEnumerable<Verifier> GetVerifiers(Object pVerifierProviderContext) {

      List<Verifier> verifiers = new List<Verifier>();

 

      verifiers.Add(GetEmailAddressVerifier());

 

      return verifiers;

    }

 

    private static Verifier GetEmailAddressVerifier() {

      NamedRegexPattern emailPattern = new NamedRegexPattern("Email", @"\b[\w.%-]+@[\w.]+\.[a-zA-Z]{2,4}\b");

      RegexVerifier v = new RegexVerifier(Descriptors.PersonalEmail, true, emailPattern);

      v.ExecutionModes = VerifierExecutionModes.OnPresetTriggers;

      return v;

    }

    #endregion

Any of the above should work, but #3 is perhaps the cleanest, and will require no change on your part when the next release comes out.



Edited by eileenv - 18-Oct-2007 at 3:52pm
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 15-Oct-2007 at 11:51am
What am I doing wrong?
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 13-Oct-2007 at 10:22am
It still fails with that. Valid or not valid email. Then it doesn't let you out of the textbox.
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 12-Oct-2007 at 3:39pm
You shouldn't have to call AddTrigger since it is already added via the RegexVerifier constructor. Have you tried the following?
 
private static Verifier GetEmailAddressVerifier(PropertyDescriptor pEmailDescriptor)

    {

        RegexVerifier v = new RegexVerifier(pEmailDescriptor, true, NamedRegexPattern.Email);

        v.ExecutionModes = VerifierExecutionModes.OnPresetTriggers;

        return v;

       

    }

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 12-Oct-2007 at 9:31am
When I run the below validation on an Email address it always fails and then I can not leave the box :

RegexVerifier v = new RegexVerifier(Descriptors.EmailAddress, true, NamedRegexPattern.Email);

v.AddTrigger(pEmailDescriptor);

v.ExecutionModes = VerifierExecutionModes.InstanceAndOnPresetTriggers;

return v;

 
To try a different method, and try and trace the error a bit further, I did the below validation and got the following validation error: ((IdeaBlade.Verification.VerifierResults)(verify)).Verifier is null

private static VerifierResult ValidEmailCondition(Email pEmail, TriggerContext triggerContext, VerifierContext verifierContext)

{

RegexVerifier v = new RegexVerifier(Descriptors.EmailAddress, true, NamedRegexPattern.Email);

      VerifierResult verify = v.Verify(pEmail.EmailAddress, triggerContext, verifierContext);

      return verify;

       

    }

private static Verifier EmailAddressVerifier(PropertyDescriptor pEmailDescriptor)

{

string description = "Email address must in a valid email format.";

      DelegateVerifier<Email> verifier = new DelegateVerifier<Email>(description, ValidEmailCondition);

      verifier.ExecutionModes = VerifierExecutionModes.InstanceAndOnPresetTriggers;

      verifier.AddTrigger(pEmailDescriptor);

      return verifier;

}

Why is any email address always failing?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down