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

Validation Bullets

 Post Reply Post Reply
Author
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 Topic: Validation Bullets
    Posted: 09-Oct-2007 at 1:27pm
I have just created my first Verifier for an EmailAddress. The problem is that the validation is only being performed when the SaveAll is being used. 
 
On some of my other properties that have set lengths and such they are being thrown immidiately.  I was looking at the documentation and this is the way it is suppose to happen.
 
Is there a reason it is only verifying after a save?

    [VerifierProvider]

    public static IEnumerable<Verifier> GetVerifiers(Object pVerifierProviderContext)

    {

 

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

        verifiers.Add(GetEmailAddressVerifier(Descriptors.Email));

 

        return verifiers;

    }

 

      private static Verifier GetEmailAddressVerifier(PropertyDescriptor pEmailDescriptor)

    {

        return new RegexVerifier(pEmailDescriptor, true, NamedRegexPattern.Email);

    }



Edited by orcities - 09-Oct-2007 at 1:27pm
Back to Top
TrevLeyb View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jun-2007
Location: New Zealand
Posts: 9
Post Options Post Options   Quote TrevLeyb Quote  Post ReplyReply Direct Link To This Post Posted: 09-Oct-2007 at 2:04pm
I don't know if it will help, but there is a white paper which discusses Verification and how to use it available from the Ideablade website. I think it answers your question on when triggering and verification is fired.
 
I'd be keen on any feedback anyway (I am the author) if it does not cover topics which you feel it should.
 
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: 09-Oct-2007 at 2:10pm
I will take a look at it and let you know.
Back to Top
TrevLeyb View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jun-2007
Location: New Zealand
Posts: 9
Post Options Post Options   Quote TrevLeyb Quote  Post ReplyReply Direct Link To This Post Posted: 09-Oct-2007 at 2:32pm
I should have actually answered your question ;-)
 
Verification is only triggered based on the setting of the ExecutionMode which needs to be defined as PreSet, PostSet or Instance. the other thing to check is that you have turned on Before/After validation in the Object Mapper options so that it generates the BeforeSetValue and AfterSetValue calls. It is these calls that execute verification against an object when you set the value through the property.
 
Looking at your code, the verifier will only be called by the Save operation is it will be an INSTANCE verification. You need to explicitly call the verification engine asking it to verify as part of your Getter/Setter for the property that is associated with this verification (if that makes sense).
 
Trevor
 
Originally posted by orcities

I have just created my first Verifier for an EmailAddress. The problem is that the validation is only being performed when the SaveAll is being used. 
 
On some of my other properties that have set lengths and such they are being thrown immidiately.  I was looking at the documentation and this is the way it is suppose to happen.
 
Is there a reason it is only verifying after a save?
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: 10-Oct-2007 at 7:58am

From looking at the help files I original thought that it always verified. I was wrong. I added the following to get it to verify preset.

private static Verifier GetEmailAddressVerifier(PropertyDescriptor pEmailDescriptor)

    {

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

        v.AddTrigger(pEmailDescriptor);

        v.ExecutionModes = VerifierExecutionModes.OnPresetTriggers;

        return v;

       

    }

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: 10-Oct-2007 at 12:26pm

Just to clarify, verifiers that are added via the static method decorated with the [VerifierProvider] attribute, are set with ExecutionModes=InstanceAndOnPostsetTriggers by default.
 
This code would have been sufficient to execute preset:
 

private static Verifier GetEmailAddressVerifier(PropertyDescriptor pEmailDescriptor)

    {

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

        v.ExecutionModes = VerifierExecutionModes.OnPresetTriggers;

        return v;

       

    }



Edited by eileenv - 10-Oct-2007 at 12:32pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down