6.5.2 • Published 4 years ago

js-validation-serjik v6.5.2

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

JS Validation!

import in component

import Validation from 'js-validation-serjik'  

single mode

use :

let data = 'input text';  
let rule = 'string|min:10'; 
let label = "label";
  
Validation.validate(data, rule, label,true);  

Note: label can be false, and if it has string value show it in error message

result :

{  
    errors: {  
       errors: ['message number one', 'message number tow'],  
    },  
    fails: true  // boolean = if has error is true else is false  
}  

Note: if the action has validation error fails property is true and if does not has it is false

group mode

use:

let data = {  
   name: 'john',  
   last_name: 'doe',  
   age: 17,  
};

let rules = {
name: 'string|max:20',
age: 'integer',
};

let labels = { name: 'your name', last_name: 'your last name', age; 'your age' };

Validation.validate(data, rules, labels);

  
### result :  
``` javascript  
{  
    errors: {  
       field_name: ['message number one', 'message number tow'],  
       age: ['must be integer'],   
       // ...  
    },  
    fails: true  // boolean = if has error is true else is false  
}  

Rules :

Note; when use rules must be split with | like this, 'rule1|rule2|rule3...'

titledescriptionuse
stringcheck the value is stringstring
integercheck the value is numberinteger
mincheck value length lower than thismin:{number} like this min:25
maxcheck value length bigger than thismax:{number} like this max:50
requiredcheck value exist and unequal with nullrequired
incheck value is in a arrayin:1,2,3,4,... these numbers is your array indexes
start withcheck value started by thisstart_with:{letter} like this start_with:a
persian alphacheck words are persian alphapersian
english alphacheck words are english alphaenglish
emailcheck email formatemail
phonecheck phone numberphone
booleancheck value is boolboolean check is true , false , 0 or 1
urlcheck value is current url addressurl check is current target
confirmcheck is equal with passed valueconfirm:{equal value} you can pass variable of component
6.5.2

4 years ago

6.5.1

4 years ago

6.5.0

4 years ago

6.4.2

4 years ago

1.2.8

4 years ago

1.2.9

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago