Skip to content

Commit d6840a5

Browse files
committed
Package version upgraded to 2.0.0
1) Package version has updated 2) Npm version batch updated in Readme file 3) Supported and unsupported form fields are listed down in readme file. 4) Also installation steps has added. Signed-off-by: gokulakannant <gokulakannanthangaraji@gmail.com>
1 parent 5846be9 commit d6840a5

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# React Input Form Validation
22

3+
[![npm package](https://img.shields.io/npm/v/react-form-input-validation)](https://www.npmjs.com/package/react-form-input-validation)
34
[![Build Status](https://api.travis-ci.org/gokulakannant/react-form-input-validation.png?branch=master)](https://travis-ci.org/gokulakannant/react-form-input-validation)
45
[![GitHub license](https://img.shields.io/github/license/gokulakannant/react-form-input-validation.svg)](https://github.com/gokulakannant/react-form-input-validation/blob/master/LICENSE.md)
56

6-
A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to validate the react forms.
7+
A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to validate the react forms. It uses the [Controlled Components](https://reactjs.org/docs/forms.html#controlled-components) approach for validation.
78

89
* [Supported Rules](https://www.npmjs.com/package/validatorjs#available-rules) (It is supports all validatorjs rules)
910
* [Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/index.html)
@@ -17,6 +18,22 @@ A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to
1718
* Readable and declarative validation rules which is inspired by laravel framework.
1819
* Error messages with multilingual support.
1920

21+
## Installation
22+
23+
To install the stable version:
24+
25+
Using [npm](https://www.npmjs.com/) as your package manager.
26+
27+
```bash
28+
npm install --save react-form-input-validation
29+
```
30+
31+
Using [yarn](https://yarnpkg.com/en/) as your package manager.
32+
33+
```bash
34+
yarn add react-form-input-validation
35+
```
36+
2037
## Usage
2138

2239
A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/index.html).
@@ -117,14 +134,40 @@ Refer the below example to override the attribute name,
117134
onBlur={this.form.handleBlurEvent}
118135
onChange={this.form.handleChangeEvent}
119136
value={this.state.fields.name}
120-
data-attribute-name="USER NAME"
137+
data-attribute-name="Username"
121138
/>
122139
```
123140

124-
The output will be like, "The USER NAME field is required.".
141+
The output will be like, "The Username field is required.".
125142

126143
## Supported form fields
127144

145+
|Form Fields and Attributes|Support By Library|
146+
| :-- |:--:|
147+
|text|&#x2611;|
148+
|password|&#x2611;|
149+
|email|&#x2611;|
150+
|url|&#x2611;|
151+
|number|&#x2611;|
152+
|checkbox|&#x2611;|
153+
|radio|&#x2611;|
154+
|search|&#x2611;|
155+
|tel|&#x2611;|
156+
|date|&#x2611;|
157+
|month|&#x2611;|
158+
|week|&#x2611;|
159+
|time|&#x2611;|
160+
|datetime-local|&#x2611;|
161+
|textarea|&#x2611;|
162+
|select|&#x2611;|
163+
|color|&#x2611;|
164+
|Combo Box Fields|&#x2611;|
165+
|file|&#x2612;|
166+
|range|&#x2612;|
167+
|image|&#x2612;|
168+
169+
The input types button, submit, reset, hidden are exceptional from the above list.
170+
128171
## Versions
129172

130173
Latest Version: 2.0.0. For more versions refer [VERSIONS.md](VERSIONS.md).

example/src/Form.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,8 @@ class ValidationForm extends React.Component {
3232
extras: "required|array"
3333
});
3434

35-
this.form.addEventListener("formsubmit", (fields) => {
36-
console.log("1st reactsubmit", fields);
37-
});
38-
39-
this.form.addEventListener("formsubmit", (fields) => {
40-
console.log("2nd reactsubmit", fields);
41-
});
42-
43-
this.form.onformsubmit = (fields) => {
44-
console.log("1st onformsubmit", fields);
45-
}
46-
4735
this.form.onformsubmit = (fields) => {
48-
console.log("2nd onformsubmit", fields);
36+
console.log(fields);
4937
}
5038

5139
ReactFormValidation.registerAsync('username_available', function(username, attribute, req, passes) {
@@ -82,7 +70,7 @@ class ValidationForm extends React.Component {
8270
onChange={this.form.handleChangeEvent}
8371
value={this.state.fields.customer_name}
8472
// To override the attribute name
85-
data-attribute-name="CUSTOMER NAME"
73+
data-attribute-name="Customer Name"
8674
data-async
8775
/>
8876
</label>
@@ -221,11 +209,12 @@ class ValidationForm extends React.Component {
221209

222210
<p>
223211
<label>
224-
Pickup Date/Time
212+
Pickup Date
225213
<input
226214
type="date"
227215
name="pickup_time"
228216
onChange={this.form.handleChangeEvent}
217+
onBlur={this.form.handleBlurEvent}
229218
value={this.state.fields.pickup_time}
230219
/>
231220
</label>
@@ -244,6 +233,7 @@ class ValidationForm extends React.Component {
244233
name="pickup_place"
245234
value={this.state.fields.pickup_place}
246235
onChange={this.form.handleChangeEvent}
236+
onBlur={this.form.handleBlurEvent}
247237
>
248238
<option value="">Select One</option>
249239
<option value="office">Taxi Office</option>
@@ -266,6 +256,7 @@ class ValidationForm extends React.Component {
266256
name="dropoff_place"
267257
value={this.state.fields.dropoff_place}
268258
onChange={this.form.handleChangeEvent}
259+
onBlur={this.form.handleBlurEvent}
269260
list="destinations"
270261
/>
271262
</label>

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-form-input-validation",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "A validator package to validate the react forms",
55
"main": "./dist/bundle.js",
66
"license": "GPLv3",

0 commit comments

Comments
 (0)