New Posts New Posts RSS Feed: How to override default verifiers offered by Devforce
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Forum LockedHow to override default verifiers offered by Devforce

 Post Reply Post Reply
Author
pchavan2009 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Nov-2009
Location: India
Posts: 6
Post Options Post Options   Quote pchavan2009 Quote  Post ReplyReply Direct Link To This Post Topic: How to override default verifiers offered by Devforce
    Posted: 15-Dec-2009 at 3:04am

In my Employee Class, property EmpName cannot be blank.

In the ServerModelDesigner, the StringLengthVerifier is added with IsRequired set to true, due to which the devforce's default validation message "EmpName is required" gets displayed when we call the VerifierEngine.Execute(...) function.
 
We have partial class of Employee where we create verifiers related to Employee.
We need to override the StringLengthVerifier created in the ServerModelDesigner and show our custom message as to "Employee Name is required" instead of "EmpName is required".
 
So when we call the VerifierEngine.Execute(...)  function, it should return only one VerifierResult "Employee Name is required"
 
Can any one please respond with a solution?
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 17-Dec-2009 at 4:51pm

pchavan:

You can set up a PropertyNameToDisplayNameTranslator delegate to make verifiers use the display name instead of the property name in their messages, as follows:

_entityManager.VerifierEngine.PropertyNameToDisplayNameTranslator =

  delegate(Type pType, String pPropertyName) {

    var attr = ReflectionFns.GetAttribute<DisplayAttribute>(pType.GetProperty(pPropertyName));

return attr.Name;

};

 
Then just set the Display Names for your properties, as desired, in the Object Mapper -- e.g., set the Display Name for the EmpName property to "Employee Name" -- and the verifier will use that name in the message.
 
 
 
 
Back to Top
pchavan2009 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Nov-2009
Location: India
Posts: 6
Post Options Post Options   Quote pchavan2009 Quote  Post ReplyReply Direct Link To This Post Posted: 17-Dec-2009 at 9:42pm
Thanks a lot! it worked
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down