ts-nano-form
A simple and versatile way of working with forms. Lightweight and dependency free.
Made with ❤️ by lehnihon & contributors
Documentation
Visit https://lehnihon.github.io/ts-nano-form-docs/ to view the documentation.
Getting Started
Install
npm install ts-nano-form
Quickstart
First initialize the main NanoForm object.
import NanoForm from "ts-nano-form";
const TsNanoForm = NanoForm();
For each form, create a component with the createForm method. Validation is done by the resolver.
import NanoForm from "ts-nano-form";
type FormUserType = {
name: string;
};
const resolver = (data: any) => {
const errors = {
name: "",
};
if (!data.name) errors.name = "name required";
return errors;
};
const TsNanoForm = NanoForm();
const { createForm } = TsNanoForm;
createForm<FormUserType>({
name: "form-user",
resolver,
});
export default TsNanoForm;
The fields are filled in and returned by the setValue and getValue methods
import TsNanoForm from "./nanoForm";
const { field } = TsNanoForm.getForm("form-user");
const { getValue, setValue } = field("name");
setValue("user name");
getValue();
//user name
The submit method validate all fields by the resolver and the fields are returned via the data parameter.
import TsNanoForm from "./nanoForm";
const { submit } = TsNanoForm.getForm("form-user");
submit((data) => console.log("submit", data));
License
Related Packages
SDK de monitoramento e auditoria de erros em tempo real | Dev Inspector
Universal, modern toast notification engine for all JavaScript frameworks and pl...
Extension of decorator validation to ui elements to allow for web integration
Version History
| Version | Released | License |
|---|---|---|
| 0.2.13 | MIT | |
| 0.2.12 | MIT | |
| 0.2.11 | MIT | |
| 0.2.10 | MIT | |
| 0.2.9 | MIT | |
| 0.2.8 | MIT | |
| 0.2.7 | MIT | |
| 0.2.6 | MIT | |
| 0.2.5 | MIT | |
| 0.2.4 | MIT | |
| 0.2.3 | MIT | |
| 0.2.2 | MIT | |
| 0.2.1 | MIT | |
| 0.2.0 | MIT | |
| 0.1.9 | MIT | |
| 0.1.8 | MIT | |
| 0.1.7 | MIT | |
| 0.1.6 | MIT | |
| 0.1.5 | MIT | |
| 0.1.4 | MIT | |
| 0.1.3 | MIT | |
| 0.1.2 | MIT | |
| 0.1.1 | MIT | |
| 0.1.0 | MIT | |
| 0.0.23 | MIT | |
| 0.0.22 | MIT | |
| 0.0.21 | MIT | |
| 0.0.20 | MIT | |
| 0.0.19 | MIT | |
| 0.0.18 | MIT |
Showing the latest 30 of 46. See every release on npm