Comparing version 0.0.7 to 0.0.8
@@ -55,11 +55,16 @@ "use strict"; | ||
_this.onSubmit = function (callback) { | ||
// Has validation ? | ||
if (_this.props.validation) { | ||
var errors = _this.validate(_this.state.values); | ||
// Is there any errors ? | ||
if (Object.keys(errors).length > 0) { | ||
// There are errors, so don't submit this Form | ||
_this.setState({ | ||
errors: errors | ||
}); | ||
return function () { | ||
// Has validation ? | ||
if (_this.props.validation) { | ||
var errors = _this.validate(_this.state.values); | ||
// Is there any errors ? | ||
if (Object.keys(errors).length > 0) { | ||
// There are errors, so don't submit this Form | ||
_this.setState({ | ||
errors: errors | ||
}); | ||
} | ||
else { | ||
callback(_this.state.values); | ||
} | ||
} | ||
@@ -69,6 +74,3 @@ else { | ||
} | ||
} | ||
else { | ||
callback(_this.state.values); | ||
} | ||
}; | ||
}; | ||
@@ -113,3 +115,3 @@ /** | ||
values: this.state.values, | ||
submit: this.onSubmit | ||
submitTo: this.onSubmit | ||
}); | ||
@@ -116,0 +118,0 @@ }; |
@@ -36,3 +36,3 @@ /// <reference types="react" /> | ||
*/ | ||
submit: (callback: (values: Values) => void) => void; | ||
submitTo: (callback: (values: Values) => void) => () => void; | ||
}; | ||
@@ -39,0 +39,0 @@ export declare type MinFormsProps<V extends object, E> = { |
@@ -40,3 +40,3 @@ export type ErrorsFromValues<V extends object, E> = { [ErrorValue in keyof V]?: E }; | ||
*/ | ||
submit: (callback: (values: Values) => void) => void; | ||
submitTo: (callback: (values: Values) => void) => () => void; | ||
}; | ||
@@ -43,0 +43,0 @@ |
{ | ||
"name": "minforms", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Small and quick alternative to formik", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# MinForms | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/dderevjanik/minforms.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/dderevjanik/minforms.svg?branch=master)](https://travis-ci.org/dderevjanik/minforms) | ||
@@ -12,5 +11,5 @@ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
Formik is a really great library for building forms in Typescript React. Has great API | ||
Formik is a really great library for fast building forms in Typescript React. Has simply API | ||
and it's easy to use. **MinForms** library is not trying to replace Formik in any | ||
way, it's just a small lib which helps you to build basic forms. For complex | ||
way, it's just a small lib which helps you to build basic forms faster. For complex | ||
forms, I suggest you to use [formik](https://github.com/jaredpalmer/formik) instead. | ||
@@ -25,4 +24,4 @@ | ||
! `minforms` library is designed to provides no Fields or Custom Inputs. It only cares | ||
about values you provided, so you can build best suited Fields/Inputs for you. | ||
_! `minforms` library is designed to provides no Fields or Custom Inputs. It only cares | ||
about values you provided, so you can build best suited Fields/Inputs for you._ | ||
@@ -29,0 +28,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
22505
478
140