File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 5
5
``` js
6
6
import Form from ' react-validify'
7
7
8
- < Form rules= {{ email: ' email|required' , password: ' required|min:8' }}>
8
+ < Form
9
+ initialValues= {{email: ' test' }} // optional
10
+ rules= {{ email: ' email|required' , password: ' required|min:8' }}
11
+ >
9
12
< Input name= " email" / >
10
13
< Input name= " password" type= " password" / >
11
14
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import React from 'react';
2
2
import Validator from 'validatorjs' ;
3
3
4
4
export default class Form extends React . Component {
5
- constructor ( ) {
5
+ constructor ( { initialValues } ) {
6
6
super ( ) ;
7
- this . state = { values : { email : 'terere' } , errors : { } } ;
7
+ this . state = { values : initialValues || { } , errors : { } } ;
8
8
this . onChange = this . onChange . bind ( this ) ;
9
9
this . validate = this . validate . bind ( this ) ;
10
10
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-validify" ,
3
- "version" : " 0.0.1 " ,
3
+ "version" : " 0.0.2 " ,
4
4
"description" : " Form validation made easy" ,
5
5
"main" : " dist/form.js" ,
6
6
"directories" : {
You can’t perform that action at this time.
0 commit comments