react-form-manage 1.0.6-beta.3 → 1.0.6-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +44 -17
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.6-beta.5] - 2026-01-22
6
+
7
+ - Update README with validation rule examples (pattern, async validator)
8
+ - Remove Vite template boilerplate from docs
9
+ - Republish docs to npm
10
+
5
11
  ## [1.0.6-beta.3] - 2026-01-22
6
12
 
7
13
  - Add `ValidationRule` typing and export
package/README.md CHANGED
@@ -72,6 +72,8 @@ export default Example;
72
72
 
73
73
  `Form` sẽ đăng ký form instance trong store nội bộ và inject `value` / `onChange` vào các children của `FormItem`.
74
74
 
75
+ `ValidationRule` là type public được export để bạn mô tả rules rõ ràng trong TypeScript.
76
+
75
77
  ---
76
78
 
77
79
  ## Form API / Programmatic usage
@@ -108,6 +110,48 @@ Methods available on the form instance (populated by `Form` provider):
108
110
 
109
111
  ---
110
112
 
113
+ ## Validation rules
114
+
115
+ Hỗ trợ các rule phổ biến: `required`, `min`, `max`, `len`, `pattern`, `enum`, `whitespace`, `type` và custom `validator`. `pattern` nhận `RegExp`; `validator` nhận hàm sync/async `(value, ctx) => void | Promise<void>`.
116
+
117
+ Ví dụ pattern + required:
118
+
119
+ ```tsx
120
+ <Form formName="codeForm" initialValues={{ numericCode: "" }}>
121
+ <FormItem
122
+ name="numericCode"
123
+ rules={[
124
+ { required: true, message: "Code is required" },
125
+ { pattern: /^\d+$/, message: "Only digits are allowed" },
126
+ ]}
127
+ >
128
+ <Input placeholder="Enter digits only" />
129
+ </FormItem>
130
+ <button type="submit">Submit</button>
131
+ </Form>
132
+ ```
133
+
134
+ Custom validator (async):
135
+
136
+ ```tsx
137
+ <FormItem
138
+ name="username"
139
+ rules={[
140
+ {
141
+ validator: async (value) => {
142
+ if (!value) throw new Error("Username required");
143
+ const exists = await api.checkUser(value);
144
+ if (exists) throw new Error("Username already taken");
145
+ },
146
+ },
147
+ ]}
148
+ >
149
+ <Input placeholder="Username" />
150
+ </FormItem>
151
+ ```
152
+
153
+ ---
154
+
111
155
  ## FormList (Array field)
112
156
 
113
157
  `FormList` là render-prop component cung cấp `listFields` và các action `add`, `remove`, `move`.
@@ -186,20 +230,3 @@ Nếu bạn muốn tự sinh `.d.ts` từ JS, có thể thêm `tsconfig.types.js
186
230
  ## License
187
231
 
188
232
  Mặc định chưa thêm license — nếu muốn public, hãy thêm `LICENSE` (ví dụ MIT).
189
-
190
- # React + Vite
191
-
192
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
193
-
194
- Currently, two official plugins are available:
195
-
196
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
197
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
198
-
199
- ## React Compiler
200
-
201
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
202
-
203
- ## Expanding the ESLint configuration
204
-
205
- If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-manage",
3
- "version": "1.0.6-beta.3",
3
+ "version": "1.0.6-beta.5",
4
4
  "description": "Lightweight React form management with list and listener support.",
5
5
  "license": "MIT",
6
6
  "type": "module",