O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying validation rules to Models' fields

A huge advantage of the new data modeling class is that validation rules can be applied directly to the Model's fields. By centralizing the validation of data fields we are able to reduce code duplication and keep our application much more organized.

This recipe will cover how to define validation rules on each of our Model's fields and also how we can create our own validation rules.

How to do it...

  1. We will start this recipe with the Book Model class we defined in the previous recipes:
    Ext.define('Book', { extend: 'Ext.data.Model', fields: [{ name: 'Title', type: 'string' }, { name: 'Publisher', type: 'string' }, { name: 'ISBN', type: 'string' }, { name: 'PublishDate', type: 'date', dateFormat: 'd-m-Y' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required