PDA

View Full Version : [DUP] Model Format Validations - no matcher or message properties



darrylm
23 Mar 2012, 3:08 AM
I've added a format validation to a model that requires a regex to be entered.

The format validation object does not have properties for matcher or message - so I have added them. But when I enter the regex it as single quotes around the regex - which is not what is required for the matcher.

Anyone know how to get around this?

Here is the generated code in designer:


Ext.define('myPoliBot.store.MyFormatValidation', { extend: '',


config: {
type: 'format',
field: 'email',
matcher: '/^(([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+){0,1}$/',
message: 'must be a valid email for us'
}
});

BTW - have used the email validation object - but this seems to also imply a presence validation on email field when it is left blank.

dmulcahey
13 May 2012, 8:49 AM
- bump

Does anyone have any info on this? I am running into the same thing.

oresistemas
26 May 2013, 10:11 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.