File tree Expand file tree Collapse file tree 2 files changed +51
-4
lines changed
packages/simplr-validation Expand file tree Collapse file tree 2 files changed +51
-4
lines changed Original file line number Diff line number Diff line change
1
+ <p align =" right " >
2
+ <a href="https://npmjs.org/package/simplr-validation">
3
+ <img src="https://img.shields.io/npm/v/simplr-validation.svg?style=flat-square" alt="version" />
4
+ </a>
5
+ <a href="https://npmjs.org/package/simplr-validation">
6
+ <img src="https://img.shields.io/npm/l/simplr-validation.svg?style=flat-square" alt="license" />
7
+ </a>
8
+ </p >
9
+
10
+ <h1 align =" center " >simplr-validation</h1 >
11
+
12
+ _ This readme is WIP. There may be some inconsistency._
13
+
14
+ This package subscribes to ` simplr-forms ` store and it will validate on emitted actions.
15
+
16
+ ## Features
17
+ - Validates fields on form store actions (` FieldRegistered ` , ` ValueChanged ` , ` PropsChanged ` )
18
+ - Subscribes to form store handler and form stores to listen actions
19
+ - Premade validators like: _ Email_ , _ Required_ , _ Contains_ etc.
20
+
21
+ ## Get started
22
+
23
+ To initialise module you need to import subscriber once in your app.
24
+
25
+ ``` typescript
26
+ import { Subscriber } from " simplr-validation" ;
27
+
28
+ Subscriber .SubscriberContainer ;
29
+ ```
30
+
31
+ ## Validators example
32
+
33
+ ``` tsx
34
+ import { Form , Text , Password } from " simplr-forms-dom" ;
35
+ import { RequiredValidator , EmailValidator } from " simplr-validation/validators" ;
36
+
37
+ export function LoginForm(props : {}) {
38
+ return <Form >
39
+ <Text name = " username" >
40
+ <RequiredValidator error = " Username field is required" />
41
+ <EmailValidator error = " Username is not valid" />
42
+ </Text >
43
+ <Password name = " password" >
44
+ <RequiredValidator error = " Password field is required" />
45
+ </Password >
46
+ <button >Submit</button >
47
+ </Form >;
48
+ }
49
+ }
50
+
51
+ ```
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments