New Posts New Posts RSS Feed: Validate "custom" properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Validate "custom" properties

 Post Reply Post Reply
Author
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Topic: Validate "custom" properties
    Posted: 18-Oct-2011 at 4:47pm
I'm trying to make my partial class to play nicely with verification engine(see code below).
 
I'm trying to create new property (PasswordEx) which works.
I need to add verifier to this property. Adding it using attribute. It works. Kind of..
 
When whole entity validated - it works and I get this field warning, etc.
What I want is INotifyDataErrorInfo to work for this property so user see wrong entry right away...
 
My guess is that I need to tell VerifierEngine to run verification on this property inside my setter but can't come up with syntax to do that. Or maybe I can do it some other way?
 
Also, how would I raise INotifyPropertyChanged event from my partial class? Is there any built-in gluing in DevForce?
 
[MetadataType(typeof(MEMUserMetadata))]
    public partial class User
    {
        private string passwordEx;
        [StringLengthVerifier(MaxValue = 20, MinValue = 6, IsRequired = true, ErrorMessage = "Password Required")]
        public string PasswordEx
        {
            get
            {
                return this.passwordEx;
            }
            set
            {
                this.passwordEx = value;
            }
        }
        public string PasswordAgainEx { get; set; }
       
    }

 

 

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 18-Oct-2011 at 5:34pm
Hi Ivan,

try:

    public string PasswordEX {
      get { return passwordEX; }
      set {
        passwordEX = value;
        OnPropertyChanged(new PropertyChangedEventArgs("PasswordEX"));
      }
    }


Regards, 
   Silvio.
Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 18-Oct-2011 at 5:39pm
Silvio,
 
It doesn't raise INotifyDataErrorInfo..
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 19-Oct-2011 at 11:19am
Hi Ivan,

The snippet above will raise INotityPropertyChanged only.

For INotityDataErrorInfo, try: (in your Entity's partial class)

    [StringLengthVerifier(MaxValue = 20, MinValue = 6, IsRequired = true, ErrorMessage = "Password Required")]
    public string PasswordEX {
      get { 
        return PropertyMetadata.PasswordEX.GetValue(this);
      }
      set {
        PropertyMetadata.PasswordEX.SetValue(this, value);
      }
    }

    public partial class PropertyMetadata {
      public static readonly IbEm.DataEntityProperty<User, string> PasswordEX = new IbEm.DataEntityProperty<User, string>("PasswordEX", false, false, IbEm.ConcurrencyStrategy.None, false, null, false);
    }

Regards,
   Silvio.


Edited by sbelini - 19-Oct-2011 at 11:21am
Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 19-Oct-2011 at 1:13pm
Excellent! Working great.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down