Merge pull request #6 from LaustAxelsen/patch-2

words, spaces and special letters.
This commit is contained in:
Christian Alfoni 2015-01-07 07:09:18 +01:00
commit dc6ac20285
2 changed files with 18 additions and 0 deletions

View File

@ -497,6 +497,18 @@ Returns true if string only contains numbers
```
Returns true if string is only letters
**isWords**
```html
<MyInputComponent name="foo" validations="isWords"/>
```
Returns true if string is only letters, including spaces and tabs
**isWordsSpecial**
```html
<MyInputComponent name="foo" validations="isWordsSpecial"/>
```
Returns true if string is only letters, including special letters (a-z,ú,ø,æ,å)
**isLength:min**, **isLength:min:max**
```html
<MyInputComponent name="foo" validations="isLength:8"/>

View File

@ -16,6 +16,12 @@ var validationRules = {
'isAlpha': function (value) {
return value.match(/^[a-zA-Z]+$/);
},
'isWords': function (value) {
return value.match(/^[a-zA-Z\s]+$/);
},
'isWordsSpecial': function (value) {
return value.match(/^[a-zA-Z\s\u00C0-\u017F]+$/);
},
isLength: function (value, min, max) {
if (max !== undefined) {
return value.length >= min && value.length <= max;