Skip to content

Travis CI configured #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ typedocconfig.ts
webpack.config.js
tslint.json
dist/typedocconfig.d.ts
Documentation/
node_modules/
.travis.yml
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- 7
- 8
- 9
- 10
install: npm install
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# React Input Form Validation

A customized validatorjs library to validate the react forms. This library is extended version of [validatorjs](https://www.npmjs.com/package/validatorjs).
[![Build Status](https://api.travis-ci.org/gokulakannant/react-form-input-validation.png?branch=master)](https://travis-ci.org/gokulakannant/react-form-input-validation)
[![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)

A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to validate the react forms.

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

## Why use react-form-input-validation?

* JQuery Free
* Auto Controlled State
* JQuery Free.
* Auto Controlled State.
* Compatible with libraries like [Material UI](https://material-ui.com/), and etc.
* Readable and declarative validation rules which is inspired by laravel framework.
* Error messages with multilingual support.

## Usage

A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/classes/reactformvalidator.html)
A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/classes/reactformvalidator.html).

```js
import React from "react";
Expand Down Expand Up @@ -106,7 +110,7 @@ class ValidationForm extends React.Component {

## Custom attribute name

Refer the below example to override the attribute name
Refer the below example to override the attribute name,

```html
<input
Expand All @@ -119,8 +123,8 @@ Refer the below example to override the attribute name
/>
```

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

## License

This project is licensed under the GPLv3 License - see the [LICENSE.md](LICENSE.md) file for details
This project is licensed under the GPLv3 License - see the [LICENSE.md](LICENSE.md) file for details.
85 changes: 82 additions & 3 deletions src/types/ReactTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,96 @@ interface IAppState {
isOwnUpdate?: boolean;
}
interface IAppProps { }
export interface IReactComponent extends Component<IAppProps, IAppState> {

export interface IReactComponent extends Component<IAppProps, IAppState> { }
export enum Lang {
ar = "ar",
az = "az",
be = "be",
bg = "bg",
bs = "bs",
ca = "ca",
cs = "cs",
cy = "cy",
da = "da",
de = "de",
el = "el",
en = "en",
es = "es",
et = "et",
eu = "eu",
fa = "fa",
fi = "fi",
fr = "fr",
hr = "hr",
hu = "hu",
id = "id",
it = "it",
ja = "ja",
ka = "ka",
ko = "ko",
It = "It",
Iv = "Iv",
mk = "mk",
mn = "mn",
ms = "ms",
nb_NO = "nb_NO",
nl = "nl",
pl = "pl",
pt = "pt",
pt_BR = "pt_BR",
ro = "ro",
ru = "ru",
se = "se",
sl = "sl",
sq = "sq",
sr = "sr",
sv = "sv",
tr = "tr",
ua = "ua",
uk = "uk",
vi = "vi",
zh = "zh",
zh_TW = "zh_TW",
}
/**
* A dictionary object to have options
* @example
* ```js
* let options = {
* locale: "en"
* }
* ```
*/
export interface IOptions {
locale: string;
/**
* The supported languages are {@link Lang}
*/
locale: Lang;
}
/**
* A dictionary object.
* @example
* ```js
* {
* has: true,
* message: "The name field is required"
* }
* ```
*/
interface IError {
/**
* Denotes has error
*/
has: boolean;
/**
* Denotes corresponding error message
*/
message: string;
}

export interface IInputErrors {
/**
* Denotes all input errors
*/
[key: string]: IError;
}