CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Suppress specific validation rule

Answered (Not Verified) This post has 0 verified answers | 1 Reply | 1 Follower

Not Ranked
3 Posts
Maxime Gaudreault Proulx posted on Mon, May 28 2012 2:33 PM

Hi, I was wondering if there is a way to suppress a specific validation rule when calling ICheckRules.CheckRules? 

I have a Name property on an object, and it has 2 rules registered to it: a Required rule, and an async NameUnique rule, which checks in the database if the name already exists. 

Since in the UI the Name field is updated on PropertyChanged, I don't want the server to be called on each key pressed. So I would like to check the unique name only when the user saves and I call CheckRules explicitely. 

Is there a way to do this? 

All Replies

Top 10 Contributor
1,765 Posts
Suggested by JonnyBee

Add the NameUniqueRule as an Object rule (ie PrimaryProperty = null) will make the rule run only when CheckRules or <bo>.CheckObjectRules is called.

An object level rule can add Error/Warn/Info messages to any property in the object.

Jonny Bekkum, Norway CslaContrib Coordinator

Page 1 of 1 (2 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems