PDA

View Full Version : [DUP] Data Model Validations: Format Validation



Artistan
3 Jan 2012, 11:33 AM
Does not have a Property for matcher regex.

aconran
10 Jan 2012, 3:20 PM
Please post a code snippet of what you are looking to define in the Designer that you are unable to.

Artistan
12 Jan 2012, 7:01 AM
http://www.sencha.com/learn/using-validations-and-associations-in-sencha-touch
format with a "matcher"
There is no matcher property on the Format Validation Component.



Ext.ns('MyApp'); MyApp.Product = Ext.regModel('Product', { fields: [ {name: 'id', type: 'int'}, {name: 'user_id', type: 'int'}, {name: 'name', type: 'string'}, {name: 'price', type: 'float'}, {name: 'sku', type: 'string'} ], validations: [ {type: 'presence', name: 'name'}, {type: 'format', name: 'sku', matcher: /[0-9]{4}[A-Z]+/}, {type: 'length', name: 'name', min: 3} ], proxy: { type: 'localstorage', id : 'products' } });

thermos192
14 Mar 2012, 11:16 AM
I tried adding a matcher by typing it in the filter list box and clicking the add button, it puts the value inside tics though so regular expressions don't work. Manually taking the tics out in the code works but of course designer saves over it. Adding it to the file outside of designer works but then designer doesn't see it when the project is loaded.

Is there a way to add something with the filter box without designer putting quotes around it in the code?

oresistemas
26 May 2013, 10:13 PM
You can try to use the matcher as an object and put the value of the object between slashs ("/"), for example:

/^[-]?[0-9]*[.]{0,1}[0-9]*$/

In my case this results in:
{
type: 'format',
message: 'Format error',
matcher: /^[-]?[0-9]*[.]{0,1}[0-9]*$/,
field: 'field01'
}


I hope this can help you.