1.0.6 • Published 6 years ago

a-plus-forms-json-validator v1.0.6

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

A+ Forms JSON Schema Validator

This a plugin for the A+ forms that enables JSON schemas based forms validation.

Installation

npm install a-plus-forms
npm install a-plus-forms-json-validator

Usage

import { Form, ValidatorProvider, EmailInput, PasswordInput } from 'a-plus-forms';
import Validator from 'a-plus-forms-json-validator';

const schema = {
  type: 'object',
  properties: {
    email: { type: 'string', format: 'email' },
    password: { type: 'string' }
  },
  required: ['email', 'password']
};

const SignInForm = ({ onSubmit }) =>
  <ValidatorProvider validator={Validator}>
    <Form schema={schema} onSubmit={onSubmit}>
      <EmailInput name="username" label="Username" />
      <PasswordInput name="password" label="Password" />
    </Form>
  </ValidatorProvider>;

The ValidatorProvider doesn't have to be right next to the Form. The best practice is to place it next to your redux store provider or such, at the app root scope level.

Copyright & License

All code in this repo is released under the terms of the MIT license. Copyright (C) 2017 Niklay Nemshilov

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.0

7 years ago