Print Page | Close Window

Validation

Printed From: IdeaBlade
Category: Breeze
Forum Name: Community Forum
Forum Discription: Build rich JavaScript apps using techniques you already know
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3787
Printed Date: 28-Apr-2024 at 5:37am


Topic: Validation
Posted By: johnvarney
Subject: Validation
Date Posted: 09-Nov-2012 at 6:56am
I've recently added Breeze to a project using Knockout and ASP.NET MVC4. I really like Breeze and it saves a lot of coding.
 
I have used Knockout validation and like how it validates a property field text box on data entry and the way the error message is displayed.
 
I would like to use a combination where the validation requirements are defined in the back-end with C# attributes on the object properties, the validation requirements are received in the metadata and then Knockout validation can be used.
 
I think I can work around it by defining the properties in the front end and applying Knockout validation eg
 
classProperty.extend({ required: true })
            .extend({ minLength: 3 });

Is there a way to use Knockout validation without having to apply the validation requirements in the front-end? If not, are you considering doing this?

Thanks,
John




Replies:
Posted By: jtraband
Date Posted: 13-Nov-2012 at 9:57am
As you've probably noticed,  Breeze already performs validations based on metadata.  Basic "validation" rules such as whether a property is required, it's datatype and it's length if a string are automatically generated on the server and sent down to the client.  These validation rules can also be extended by directly modifying the "validation" metadata on the client. 

More information on this topic is available both within the API documentation: http://www.breezejs.com/sites/all/apidocs/classes/Validator.html%20%20 - http://www.breezejs.com/sites/all/apidocs/classes/Validator.html as well as within the "DocCode" sample directory in the Breeze Samples download.

We are also planning on providing examples of how to "connect" breeze validation to various third party libraries, such as jQuery and Knockout.  Unfortunately, these examples are not currently a high priority because of work on other highly requested features. You might want to vote for work on these examples on our Breeze User Voice  https://breezejs.uservoice.com/forums/173093-breeze-feature-suggestions - https://breezejs.uservoice.com/forums/173093-breeze-feature-suggestions . We take that venue seriously in making decisions about what to do next.




Print Page | Close Window