Skip to content

Commit 76e164a

Browse files
committed
Expose validator components. Update deps. Remove Autocomplete.
1 parent fa4552d commit 76e164a

File tree

10 files changed

+27
-424
lines changed

10 files changed

+27
-424
lines changed

Readme.md

100755100644
Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
1-
## Validation component for material-ui forms
1+
## Validation component for material-ui v1 forms
22

33
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
44
[![npm version](https://badge.fury.io/js/react-material-ui-form-validator.svg)](https://badge.fury.io/js/react-material-ui-form-validator)
55
[![Build Status](https://travis-ci.org/NewOldMax/react-material-ui-form-validator.svg?branch=master)](https://travis-ci.org/NewOldMax/react-material-ui-form-validator)
66

77
### [Demo](https://newoldmax.github.io/react-material-ui-form-validator/)
88

9+
### Installation
10+
11+
````
12+
npm install react-material-ui-form-validator@next
13+
````
14+
915
### Versions
10-
+ 0.x - supports material-ui <= 0.x
11-
+ 1.x - supports material-ui >= 1.x (experimental support, you can install it by ``npm i react-material-ui-form-validator@next``)
16+
+ 0.x, 1.x - supports material-ui <= 0.x
17+
+ 2.x - supports material-ui >= 1.x (experimental support, you can install it by ``npm i react-material-ui-form-validator@next``)
1218

13-
Simple form validation component for material-ui library inspired by [formsy-react](https://github.com/christianalfoni/formsy-react)
19+
Implementation of [react-form-validator-core](https://www.npmjs.com/package/react-form-validator-core) for [material-ui v1](https://material-ui-next.com/)
1420

1521
Supported types:
16-
+ Text ([TextValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/master/src/TextValidator.jsx))
17-
+ Select ([SelectValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/master/src/SelectValidator.jsx))
18-
+ AutoComplete ([AutoCompleteValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/master/src/AutoCompleteValidator.jsx))
19-
+ Date ([DateValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/master/src/DateValidator.jsx))
20-
+ Time ([TimeValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/master/src/TimeValidator.jsx))
21-
22-
Default validation rules:
23-
+ matchRegexp
24-
+ isEmail
25-
+ isEmpty
26-
+ required
27-
+ trim
28-
+ isNumber
29-
+ isFloat
30-
+ isPositive
31-
+ minNumber
32-
+ maxNumber
22+
+ Text ([TextValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/v1/src/TextValidator.jsx))
23+
+ Select ([SelectValidator](https://github.com/NewOldMax/react-material-ui-form-validator/blob/v1/src/SelectValidator.jsx))
3324

3425
Some rules can accept extra parameter, example:
3526
````javascript
@@ -59,7 +50,7 @@ class MyForm extends React.Component {
5950

6051
constructor(props) {
6152
super(props);
62-
53+
this.state = {};
6354
this.handleChange = this.handleChange.bind(this);
6455
}
6556

@@ -229,26 +220,6 @@ export default CheckboxValidatorElement;
229220
230221
##### [Advanced usage](https://github.com/NewOldMax/react-material-ui-form-validator/wiki)
231222
232-
### API
233-
234-
#### ValidatorForm
235-
236-
| Prop | Required | Type | Default value | Description |
237-
|-----------------|----------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------|
238-
| onSubmit | true | function | | Callback for form that fires when all validations are passed |
239-
| instantValidate | false | bool | true | If true, form will be validated after each field change. If false, form will be validated only after clicking submit button. |
240-
| onError | false | function | | Callback for form that fires when some of validations are not passed. It will return array of elements which not valid. |
241-
242-
#### All validated fields (ValidatorComponent)
243-
244-
| Prop | Required | Type | Default value | Description |
245-
|-----------------|----------|----------|---------------|----------------------------------------------------------------------------------------|
246-
| validators | false | array | | Array of validators. See list of default validators above. |
247-
| errorMessages | false | array | | Array of error messages. Order of messages should be the same as `validators` prop. |
248-
| name | true | string | | Name of input |
249-
| validatorListener | false | function | | It triggers after each validation. It will return `true` or `false` |
250-
251-
252223
### Contributing
253224
254225
This component covers all my needs, but feel free to contribute.

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-material-ui-form-validator",
3-
"version": "2.0.0-beta.3",
3+
"version": "2.0.0-beta.4",
44
"description": "Simple validator for forms designed with material-ui components.",
55
"main": "./lib/index.js",
66
"scripts": {
@@ -23,6 +23,9 @@
2323
"url": "https://github.com/NewOldMax/react-material-ui-form-validator/issues"
2424
},
2525
"homepage": "https://github.com/NewOldMax/react-material-ui-form-validator#readme",
26+
"dependencies": {
27+
"react-form-validator-core": "0.4.1"
28+
},
2629
"peerDependencies": {
2730
"material-ui": "next",
2831
"react": "^15.0.0 || ^16.0.0",

src/AutoCompleteValidator.jsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/SelectValidator.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/* eslint-disable */
22
import React from 'react';
33
import TextField from 'material-ui/TextField';
4-
import { FormHelperText } from 'material-ui/Form';
54
/* eslint-enable */
6-
import ValidatorComponent from './ValidatorComponent';
5+
import { ValidatorComponent } from 'react-form-validator-core';
76

87
export default class SelectValidator extends ValidatorComponent {
98

src/TextValidator.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react';
33
import TextField from 'material-ui/TextField';
44
/* eslint-enable */
5-
import ValidatorComponent from './ValidatorComponent';
5+
import { ValidatorComponent } from 'react-form-validator-core';
66

77
export default class TextValidator extends ValidatorComponent {
88

src/ValidationRules.jsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/ValidatorComponent.jsx

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)