Skip to content

Commit 5846be9

Browse files
committed
Changelog updated for v2.0.0
1) Documents are review and corrected the mistakes. 2) Event is renamed from onreactformsubmit to onformsubmit 3) Hierarchy is removed from documentation theme 4) Code sandbox urls are updated in the documentation 5) Readme.md, Versions.md, Changelog.md files are updated. Signed-off-by: gokulakannant <gokulakannanthangaraji@gmail.com>
1 parent b7f0dc3 commit 5846be9

File tree

8 files changed

+126
-97
lines changed

8 files changed

+126
-97
lines changed

CHANGELOG.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
# Introduction
2+
23
Documentation of React Form Input Validation API's for use of web developers validating React Forms.
34

4-
# Changelog
5+
## Changelog
6+
57
All notable changes to React Form Input Validation APIs will be documented in this file.
68

7-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
10+
11+
## [2.0.0] - 22/11/2019
12+
13+
### Added
14+
15+
- Added the following new API's
16+
- [`useRules`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#userules)
17+
- [`registerAsync`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#registerasync)
18+
- [`setAttributeFormatter`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#setattributeformatter)
19+
- [`addEventListener`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#addeventlistener)
20+
- [`removeEventListener`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#removeeventlistener)
21+
- A new custom event is introduced to provide validated form data.
22+
- [`onformsubmit`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#onformsubmit)
23+
- A custom attribute `data-async` introduced to denotes async validation form field.
24+
It should be mentioned in form field, if the form field has async validation. Refer [`registerAsync`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#registerasync) API for more details.
25+
26+
### Modified
27+
28+
- API Documentation contents has improved.
29+
- More Code Sandbox examples are added in the API document.
30+
- Modified API name from `handleFieldsChange` to [`handleChangeEvent`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#handlechangeevent).
31+
- Error message containing state `inputErrors` is renamed to `errors`.
32+
- Accessing error message in state is modified from `state.inputErrors.{form field name}.message` to `state.errors.{form field name}`.
33+
34+
### Removed
35+
36+
- [Contructor](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#constructor) arguments reduced.
37+
- Rules passing in consturctor is removed. And the alternate is [`useRules`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#userules).
38+
- Handle submit callback in constructor removed. And the alternate is [`onformsubmit`](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/classes/reactforminputvalidation.html#onformsubmit) event.
39+
40+
## [1.0.1] - 14/11/2019
941

10-
## [2.19.0] - 04/11/2019
1142
### Added
12-
- Added the enum property
43+
44+
- A limited featured package has published.

README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to validate the react forms.
77

88
* [Supported Rules](https://www.npmjs.com/package/validatorjs#available-rules) (It is supports all validatorjs rules)
9-
* [Documentation](https://gokulakannant.github.io/react-form-input-validation/index.html)
9+
* [Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/index.html)
1010
* [Demo](https://codesandbox.io/s/react-form-input-validation-demp-hyuju?fontsize=14&hidenavigation=1&theme=dark) (in CodeSandbox)
1111

1212
## Why use react-form-input-validation?
@@ -19,11 +19,11 @@ A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to
1919

2020
## Usage
2121

22-
A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/classes/reactformvalidator.html).
22+
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).
2323

2424
```js
2525
import React from "react";
26-
import ReactFormValidation from "react-form-input-validation";
26+
import ReactFormInputValidation from "react-form-input-validation";
2727

2828
class ValidationForm extends React.Component {
2929
constructor(props) {
@@ -36,17 +36,15 @@ class ValidationForm extends React.Component {
3636
},
3737
errors: {}
3838
};
39-
this.form = new ReactFormValidation(
40-
this,
41-
{
39+
this.form = new ReactFormInputValidation(this);
40+
this.form.useRules({
4241
name: "required",
4342
email: "required|email",
4443
phone_number: "required|numeric|digits_between:10,12",
45-
},
46-
(fields) => {
47-
alert(JSON.stringify(fields));
48-
}
49-
);
44+
});
45+
this.form.onformsubmit = (fields) => {
46+
// Do you ajax calls here.
47+
}
5048
}
5149

5250
render() {
@@ -59,12 +57,12 @@ class ValidationForm extends React.Component {
5957
type="text"
6058
name="name"
6159
onBlur={this.form.handleBlurEvent}
62-
onChange={this.form.handleFieldsChange}
60+
onChange={this.form.handleChangeEvent}
6361
value={this.state.fields.name}
6462
/>
6563
</label>
6664
<label className="error">
67-
{this.state.errors.name ? this.state.errors.name.message : ""}
65+
{this.state.errors.name ? this.state.errors.name : ""}
6866
</label>
6967
</p>
7068

@@ -75,12 +73,12 @@ class ValidationForm extends React.Component {
7573
type="email"
7674
name="email"
7775
onBlur={this.form.handleBlurEvent}
78-
onChange={this.form.handleFieldsChange}
76+
onChange={this.form.handleChangeEvent}
7977
value={this.state.fields.email}
8078
/>
8179
</label>
8280
<label className="error">
83-
{this.state.errors.email ? this.state.errors.email.message : ""}
81+
{this.state.errors.email ? this.state.errors.email : ""}
8482
</label>
8583
</p>
8684

@@ -91,12 +89,12 @@ class ValidationForm extends React.Component {
9189
type="tel"
9290
name="phone_number"
9391
onBlur={this.form.handleBlurEvent}
94-
onChange={this.form.handleFieldsChange}
92+
onChange={this.form.handleChangeEvent}
9593
value={this.state.fields.phone_number}
9694
/>
9795
</label>
9896
<label className="error">
99-
{this.state.errors.phone_number ? this.state.errors.phone_number.message : ""}
97+
{this.state.errors.phone_number ? this.state.errors.phone_number : ""}
10098
</label>
10199
</p>
102100
<p>
@@ -117,14 +115,20 @@ Refer the below example to override the attribute name,
117115
type="text"
118116
name="name"
119117
onBlur={this.form.handleBlurEvent}
120-
onChange={this.form.handleFieldsChange}
118+
onChange={this.form.handleChangeEvent}
121119
value={this.state.fields.name}
122120
data-attribute-name="USER NAME"
123121
/>
124122
```
125123

126124
The output will be like, "The USER NAME field is required.".
127125

126+
## Supported form fields
127+
128+
## Versions
129+
130+
Latest Version: 2.0.0. For more versions refer [VERSIONS.md](VERSIONS.md).
131+
128132
## Changelog
129133

130134
Recently Updated? Please read the [changelog](CHANGELOG.md).

VERSIONS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# React Form Input Validation Versions
2+
3+
You can come back to this page and switch the version of the docs you're reading at any time.
4+
5+
## Stable versions
6+
7+
The most recent version is recommended in production.
8+
9+
|Versions|Documents|Releases|
10+
|--------|---------|--------|
11+
|v2.0.0|[Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/index.html)|[Release notes](https://github.com/gokulakannant/react-form-input-validation/releases/tag/v2.0.0)|
12+
|v1.0.1|[Documentation](https://gokulakannant.github.io/react-form-input-validation/index.html)| |
13+
14+
## Versioning strategy
15+
16+
React Form Input Validation follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). React Form Input Validation version numbers have three parts: major.minor.patch. The version number is incremented based on the level of change included in the release.
17+
18+
* **Major releases** contain significant new features, some but minimal developer assistance is expected during the update. When updating to a new major release, you may need to run update scripts, refactor code, run additional tests, and learn new APIs.
19+
* **Minor releases** contain important new features. Minor releases are fully backward-compatible; no developer assistance is expected during update, but you can optionally modify your apps and libraries to begin using new APIs, features, and capabilities that were added in the release.
20+
* **Patch releases** are low risk, contain bug fixes and small new features. No developer assistance is expected during update.

example/src/Form.js

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

35-
this.form.addEventListener("reactformsubmit", (fields) => {
35+
this.form.addEventListener("formsubmit", (fields) => {
3636
console.log("1st reactsubmit", fields);
3737
});
3838

39-
this.form.addEventListener("reactformsubmit", (fields) => {
39+
this.form.addEventListener("formsubmit", (fields) => {
4040
console.log("2nd reactsubmit", fields);
4141
});
4242

43-
this.form.onreactformsubmit = (fields) => {
44-
console.log("1st onreactformsubmit", fields);
43+
this.form.onformsubmit = (fields) => {
44+
console.log("1st onformsubmit", fields);
4545
}
4646

47-
this.form.onreactformsubmit = (fields) => {
48-
console.log("2nd onreactformsubmit", fields);
47+
this.form.onformsubmit = (fields) => {
48+
console.log("2nd onformsubmit", fields);
4949
}
5050

5151
ReactFormValidation.registerAsync('username_available', function(username, attribute, req, passes) {
@@ -63,10 +63,9 @@ class ValidationForm extends React.Component {
6363
}
6464

6565
render() {
66-
console.log(this.state)
6766
return (
6867
<div style={{maxWidth: "600px", margin: "0 auto"}}>
69-
<h3>React Input Form Validation</h3>
68+
<h3>React Form Input Validation</h3>
7069
<form
7170
className="myForm"
7271
noValidate

src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const Validator = require("validatorjs");
22
import { IReactComponent, IOptions, IValidatorErrors, IDynamicKeyValues, ReactFormSubmitEventHandler,
3-
ReactFormInputValidation as BaseValidator } from "./specs/react-form-input-validator.spec";
3+
ReactFormInputValidation as BaseValidation } from "./specs/react-form-input-validator.spec";
44

5-
class ReactFormInputValidation extends BaseValidator {
5+
class ReactFormInputValidation extends BaseValidation {
66
private component: IReactComponent;
77
private rules: object = {};
88
private errors: IValidatorErrors = {};
9-
private _onreactformsubmit: ReactFormSubmitEventHandler;
9+
private _onformsubmit: ReactFormSubmitEventHandler;
1010

1111
constructor(component: IReactComponent, options?: IOptions) {
1212
super(component, options);
@@ -45,17 +45,17 @@ class ReactFormInputValidation extends BaseValidator {
4545
Validator.setAttributeFormatter(callbackFn);
4646
}
4747

48-
public set onreactformsubmit(callback: ReactFormSubmitEventHandler) {
49-
if (this._onreactformsubmit) {
50-
super.removeListener("reactformsubmit", this._onreactformsubmit);
48+
public set onformsubmit(callback: ReactFormSubmitEventHandler) {
49+
if (this._onformsubmit) {
50+
super.removeListener("formsubmit", this._onformsubmit);
5151
}
5252

53-
this._onreactformsubmit = callback;
54-
super.addListener("reactformsubmit", this._onreactformsubmit);
53+
this._onformsubmit = callback;
54+
super.addListener("formsubmit", this._onformsubmit);
5555
}
5656

57-
public get onreactformsubmit(): ReactFormSubmitEventHandler {
58-
return this._onreactformsubmit;
57+
public get onformsubmit(): ReactFormSubmitEventHandler {
58+
return this._onformsubmit;
5959
}
6060

6161
public addEventListener(event: string, callback: (...args: Array<any>) => void): this {
@@ -240,7 +240,7 @@ class ReactFormInputValidation extends BaseValidator {
240240
* @param details The form fields to send in the event
241241
*/
242242
private getEvent(details: any): CustomEvent {
243-
return new CustomEvent("reactformsubmit", {
243+
return new CustomEvent("formsubmit", {
244244
detail: details
245245
});
246246
}

0 commit comments

Comments
 (0)