Skip to content

Commit 040f5ad

Browse files
author
Edward Xiao
committed
Merge branch 'master' of github.com:edwardfhsiao/react-inputs-validation
2 parents c3277a2 + c18b44b commit 040f5ad

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ import { Textbox, Textarea, Radiobox, Checkbox, Select } from 'react-inputs-vali
2323
import 'react-inputs-validation/lib/react-inputs-validation.min.css';
2424
```
2525
# Codesandbox Examples
26-
* <a href="https://codesandbox.io/s/v3wq0llmo3">Online demo form example playground</a>
27-
* <a href="https://codesandbox.io/s/pjom8r78x7">Custom control</a>(when ```check: false```)
28-
* <a href="https://codesandbox.io/s/1r77ozkrk7">Custom function</a>(when providing ```customFunc```)
26+
* <a href="https://codesandbox.io/s/v3wq0llmo3">Example of online demo form playground</a>
27+
* <a href="https://codesandbox.io/s/pjom8r78x7">Example of custom control</a>(when ```check: false```)
28+
* <a href="https://codesandbox.io/s/1r77ozkrk7">Example of custom function</a>(when providing ```customFunc```)
2929
* <a href="https://codesandbox.io/s/custom-function-further-control-when-providing-customfunc-yjwch">Custom function further control</a>(when providing ```customFunc```)
30-
* <a href="https://codesandbox.io/s/q9vqmk4j84">Custom locales</a>(when providing ```window.REACT_INPUTS_VALIDATION['customErrorMessage']```)
31-
* <a href="https://codesandbox.io/s/13qo2rqxjj">Phone and email validation example</a>(handled with ```customFunc```)
32-
* <a href="https://codesandbox.io/s/asyncmsgobj-blmce">asyncMsgObj example</a>(when providing ```asyncMsgObj```)
30+
* <a href="https://codesandbox.io/s/q9vqmk4j84">Example of custom locales</a>(when providing ```window.REACT_INPUTS_VALIDATION['customErrorMessage']```)
31+
* <a href="https://codesandbox.io/s/13qo2rqxjj">Example of phone and email validation</a>(handled with ```customFunc```)
32+
* <a href="https://codesandbox.io/s/async-checking-via-customfunc-emqgw">Example of async checking username existence </a>(Async checking for ```<Textbox>``` and ```<Textarea>``` only. Handled with ```customFunc```)
33+
* <a href="https://codesandbox.io/s/asyncmsgobj-blmce">Example of asyncMsgObj </a>(when providing ```asyncMsgObj```)
3334

3435
# Docs Link
3536
[Textbox](#Textbox)
@@ -44,7 +45,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
4445

4546
[Custom Error Message Guid(can be multiple locales)](#custom-error-message)
4647

47-
[Phone and email validation example](#phone-email-validation-example)(Since the phone and email validation are no longer handled internally after v1.4.0.)
48+
[Example of phone and email validation](#phone-email-validation-example)(Since the phone and email validation are no longer handled internally after v1.4.0.)
4849

4950
# Installation
5051
```sh
@@ -94,15 +95,15 @@ Tested on IE9+ and Chrome and Safari(10.0.3)
9495
|**validationOption.max** |**Opt**|**Num**|**Validation of max length when validationOption['type'] is string, max amount when validationOption['type'] is number.**|**0** |
9596
|**validationOption.length** |**Opt**|**Num**|**Validation of exact length of the value.**|**0** |
9697
|**validationOption.compare** |**Opt**|**Str** |**Compare this value to 3 to see if they are equal.**|**""** |
97-
|**<a name="customFunc"></a>validationOption.customFunc** |**Opt**|**Func**|**Custom function. Returns true or err message.**| **none** |
98+
|**<a name="customFunc"></a>validationOption.customFunc** |**Opt**|**Func**|**Custom function. Returns true or err message or { error: true, message: 'message', showOnSuccess: true }.**| **none** |
9899
|**validationOption.reg** |**Opt**|**Bool**|**Custom regex.**|**""** |
99100
|**validationOption.regMsg** |**Opt**|**Str** |**Custom regex error message.**|**""** |
100101
|**validationOption.locale** |**Opt**|**Str** |**For error message display. Current options are ['zh-CN', 'en-US']; Default is 'en-US'. If your are looking for more options, you can take a look at '[window.REACT_INPUTS_VALIDATION](#custom-error-message)' section, which provides the extensibility for your own locale.**|**"en-US"** |
101-
|~~**validationOption.phoneCountry**~~|~~**Opt**~~|~~**Str**~~|~~**Useful when the validationOption['type'] is phone. Check if the phone number matchs en-US phone number format.**~~ <br><br>**No longer support after v1.4.0. For phone or email address validation please reffer to '[Phone and email validation example](#phone-email-validation-example)'**|~~**"en-US"**~~|
102+
|~~**validationOption.phoneCountry**~~|~~**Opt**~~|~~**Str**~~|~~**Useful when the validationOption['type'] is phone. Check if the phone number matchs en-US phone number format.**~~ <br><br>**No longer support after v1.4.0. For phone or email address validation please reffer to '[Example of phone and email validation](#phone-email-validation-example)'**|~~**"en-US"**~~|
102103
|**validationOption.msgOnError** |**Opt**|**Str** |**Show your custom error message no matter what(except the message from customFunc) when it has error if it is provied.**|**""** |
103104
|**validationOption.msgOnSuccess** |**Opt**|**Str** |**Show your custom success message no matter what when it has error if it is provied.**|**""** |
104105
|**asyncMsgObj.error** |**Opt**|**Bool** |**(Server response) Backend validation result.**|**false** |
105-
|**asyncMsgObj.message** |**Opt**|**Str** |**(Server response) Your AJAX message. For instance, provide it when backend returns 'USERNAME ALREADY EXIST'**|**""** |
106+
|**asyncMsgObj.message** |**Opt**|**Str** |**(Server response) Your AJAX message. For instance, provide it when backend returns 'USERNAME ALREADY EXIST' (For Textbox or Textarea, better reffer to <a href="https://codesandbox.io/s/async-checking-via-customfunc-emqgw">Example of async checking username existence </a>**|**""** |
106107
|**asyncMsgObj.showOnError** |**Opt**|**Bool** |**(Server response) Show AJAX error message or not.**|**true** |
107108
|**asyncMsgObj.showOnSuccess** |**Opt**|**Bool** |**(Server response) Show AJAX success message or not.**|**false** |
108109

@@ -152,7 +153,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
152153
// locale: 'en-US', //Optional.[String].Default: "en-US". For error message display. Current options are ['zh-CN', 'en-US']; Default is 'en-US'. If your are looking for more options, you can take a look at 'window.REACT_INPUTS_VALIDATION' section, which provides the extensibility for your own locale.
153154
// msgOnError: "Your custom error message if you provide the validationOption['msgOnError']", //Optional.[String].Default: "" Show your custom error message no matter what(except the message from customFunc) when it has error if it is provied.
154155
// msgOnSuccess: "Your custom success message if you provide the validationOption['msgOnSuccess']. Otherwise, it will not show, not even green border.", //Optional.[String].Default: "". Show your custom success message no matter what when it has error if it is provied.
155-
// customFunc: res => { //Optional.[Func].Default: none. Custom function. Returns true or err message
156+
// customFunc: res => { //Optional.[Func].Default: none. Custom function. Returns true or err message or { error: true, message: 'message', showOnSuccess: true }
156157
// if (res != 'milk') {
157158
// return 'Description cannot be other things but milk';
158159
// }
@@ -499,14 +500,14 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
499500
|**validationOption.min** |**Opt**|**Num**|**Validation of min length.**|**0** |
500501
|**validationOption.max** |**Opt**|**Num**|**Validation of max length.**|**0** |
501502
|**validationOption.length** |**Opt**|**Num**|**Validation of exact length of the value.**|**0** |
502-
|**validationOption.customFunc** |**Opt**|**Func**|**Custom function. Returns true or err message.**| **none** |
503+
|**validationOption.customFunc** |**Opt**|**Func**|**Custom function. Returns true or err message or { error: true, message: 'message', showOnSuccess: true }.**| **none** |
503504
|**validationOption.reg** |**Opt**|**Bool**|**Custom regex.**|**""** |
504505
|**validationOption.regMsg** |**Opt**|**Str** |**Custom regex error message.**|**""** |
505506
|**validationOption.locale** |**Opt**|**Str** |**For error message display. Current options are ['zh-CN', 'en-US']; Default is 'en-US'. If your are looking for more options, you can take a look at '[window.REACT_INPUTS_VALIDATION](#custom-error-message)' section, which provides the extensibility for your own locale.**|**"en-US"** |
506507
|**validationOption.msgOnError** |**Opt**|**Str** |**Show your custom error message no matter what(except the message from customFunc) when it has error if it is provied.**|**""** |
507508
|**validationOption.msgOnSuccess** |**Opt**|**Str** |**Show your custom success message no matter what when it has error if it is provied.**|**""** |
508509
|**asyncMsgObj.error** |**Opt**|**Bool** |**(Server response) Backend validation result.**|**false** |
509-
|**asyncMsgObj.message** |**Opt**|**Str** |**(Server response) Your AJAX message. For instance, provide it when backend returns 'USERNAME ALREADY EXIST'**|**""** |
510+
|**asyncMsgObj.message** |**Opt**|**Str** |**(Server response) Your AJAX message. For instance, provide it when backend returns 'USERNAME ALREADY EXIST' (For Textbox or Textarea, better reffer to <a href="https://codesandbox.io/s/async-checking-via-customfunc-emqgw">Example of async checking username existence </a>**|**""** |
510511
|**asyncMsgObj.showOnError** |**Opt**|**Bool** |**(Server response) Show AJAX error message or not.**|**true** |
511512
|**asyncMsgObj.showOnSuccess** |**Opt**|**Bool** |**(Server response) Show AJAX success message or not.**|**false** |
512513
@@ -556,7 +557,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
556557
// regMsg: 'failed in reg.test(${value})', //Optional.[String].Default: "". Custom regex error message.
557558
// msgOnError: "Your custom error message if you provide the validationOption['msgOnError']", //Optional.[String].Default: "". Show your custom error message no matter what(except the message from customFunc) when it has error if it is provied.
558559
// msgOnSuccess: "Your custom success message if you provide the validationOption['msgOnSuccess']. Otherwise, it will not show, not even green border.", //Optional.[String].Default: "". Show your custom success message no matter what when it has error if it is provied.
559-
// customFunc: res => { //Optional.[Func].Default: none. Custom function. Returns true or err message
560+
// customFunc: res => { //Optional.[Func].Default: none. Custom function. Returns true or err message or { error: true, message: 'message', showOnSuccess: true }
560561
// if (res != 'banana') {
561562
// return 'Description cannot be other things but banana';
562563
// }
@@ -572,7 +573,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
572573
/>
573574
```
574575
575-
### <a name="phone-email-validation-example"></a>Phone and email validation example
576+
### <a name="phone-email-validation-example"></a>Example of phone and email validation
576577
<a href="https://codesandbox.io/s/13qo2rqxjj">codesandbox example</a>
577578
```js
578579
import validator from 'validator';
@@ -594,7 +595,7 @@ import 'react-inputs-validation/lib/react-inputs-validation.min.css';
594595
}
595596
}}
596597
/>
597-
598+
598599
// Email
599600
<Textbox
600601
...

0 commit comments

Comments
 (0)