https://github.com/yazaabed/react-form-validations
Created with CodeSandbox
https://github.com/yazaabed/react-form-validations
Last synced: 3 months ago
JSON representation
Created with CodeSandbox
- Host: GitHub
- URL: https://github.com/yazaabed/react-form-validations
- Owner: yazaabed
- Created: 2018-05-23T23:58:11.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T00:01:35.000Z (about 7 years ago)
- Last Synced: 2025-01-07T23:51:40.294Z (5 months ago)
- Language: JavaScript
- Homepage: https://codesandbox.io/s/github/YazanAabeed/react-form-validations
- Size: 6.84 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-form-validations
Created with CodeSandbox---
Hey, my name is Yazan,
I am searching for advice after I watch "React Advanced Pattern" Course. I got an idea to build a form with inputs without the need to handle all event for your form element.
for example this is `` with validation rules and this is the message shown
```
This field is required
```You can create your custom validation like this:
```
customeFormValidation = (id, value, rule) => {
switch (rule.code) {
case "custome-1":
return false;default:
console.warn("Missing validation for: ", rule);
}return false;
};{
if (!this.form.validator.validate()) {
} else {
console.log(this.form.validator.data);
}
}}
validator={this.form.validator}
customeFormValidation={this.customeFormValidation}
>```
I am wondering if this idea good enough to continue work within React?
I am thinking to change this to work with `React.createContext.` more flexible than the solution I add.*Note: The code is really bad! But I was learning how things work with React*