Hi,

What happened to the configuration items 'AutoValidation' and 'ValidationMode'?

Regards Paul

asked Aug 22 '14 at 03:48

Paul%20Sinnema's gravatar image

Paul Sinnema
261868896


One Answer:

Validation API was reworked in 5.0 and this configuration items was removed. Entities validates on transaction committing, on Session.SaveChanges() and on your demand by session.Validate(). If you need validate some fields immediately then you can set property IsImmediate to true for all constraints of this field.

For example,

  
  [HierarchyRoot]
  public sealed class Customer : Entity
  {
    [Field, Key]
    public int Id { get; set; }
    [Field(Length = 50), NotEmptyConstraint(IsImmediate = true)]
    public string FirstName { get; set; }
    [Field(Length = 50), NotEmptyConstraint(IsImmediate = true)]
    public string LastName { get; set; }
    [Field, PastConstraint(IsImmediate = true)]
    public DateTime Birthday { get; set; }
    [Field(Length = 128), EmailConstraint(IsImmediate = true)]
    public string Email { get; set; }
    [Field(Length = 50), RegexConstraint(@"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$", IsImmediate = true)]
    public string PhoneNumber { get; set; }
  }

All constraints in this example was marked as immediate and DO will validate them immediately after changing.

answered Aug 25 '14 at 00:36

Alexey%20Kulakov's gravatar image

Alexey Kulakov
63215

edited Aug 25 '14 at 00:41

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×5

Asked: Aug 22 '14 at 03:48

Seen: 2,115 times

Last updated: Aug 25 '14 at 00:41

powered by OSQA