Nested Public Modules

    simplr-validation
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.1-beta.7 • Public • Published

    version license

    simplr-validation

    This readme is WIP. There may be some inconsistency.

    This package subscribes to simplr-forms store and it will validate on emitted actions.

    Features

    • Validates fields on form store actions (FieldRegistered, ValueChanged, PropsChanged)
    • Subscribes to form store handler and form stores to listen actions
    • Premade validators like: Email, Required, Contains etc.

    Get started

    To initialise module you need to import subscriber once in your app.

    import { Subscriber } from "simplr-validation";
     
    Subscriber.SubscriberContainer;

    Validators example

    import { Form, Text, Password } from "simplr-forms-dom";
    import { RequiredValidator, EmailValidator } from "simplr-validation/validators";
     
    export function LoginForm(props: {}) {
            return <Form>
                <Text name="username">
                    <RequiredValidator error="Username field is required" />
                    <EmailValidator error="Username is not valid" />
                </Text>
                <Password name="password">
                    <RequiredValidator error="Password field is required" />
                </Password>
                <button>Submit</button>
            </Form>;
        }
    }
     

    Keywords

    none

    Install

    npm i simplr-validation

    DownloadsWeekly Downloads

    2

    Version

    4.0.1-beta.7

    License

    AGPL-3.0

    Last publish

    Collaborators

    • quatrodev