@egomobile/forms
v0.7.1
Published
Types and helpers, handling forms and their data.
Downloads
20
Readme
@egomobile/forms
Types and helpers, handling forms and their data.
Install
Execute the following command from your project folder, where your package.json
file is stored:
npm install --save @egomobile/forms
Usage
import { compileFormValidator, IForm } from "../src";
const form: IForm = {
version: "1",
components: [
{
class: "ETextField",
name: "lastname",
props: {
label: "Last name",
},
},
{
class: "ETextField",
name: "firstname",
props: {
label: "First name",
},
},
],
schema: {
format: "ajv",
config: {
type: "object",
required: ["lastname", "firstname"],
properties: {
firstname: {
type: "string",
},
lastname: {
type: "string",
},
},
},
},
};
async function main() {
const validate = compileFormValidator(form);
// should return 1 error
// because `firstname` has no value
const validationResult = validate({
lastname: "Doe",
});
console.log(validationResult);
}
main().catch(console.error);
Credits
The module makes use of:
Documentation
The API documentation can be found here.