@bolttech/form-engine-core 0.0.1-beta.9 → 0.0.2-beta.1

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.
package/README.md CHANGED
@@ -7,6 +7,7 @@ Achieve form logic re-usage with forms expressed in json format.
7
7
  1. [Basic setup](#markdown-header-basic-setup)
8
8
  2. [Step by step](#markdown-header-step-by-step)
9
9
  3. [Form Features](#markdown-header-available-features)
10
+
10
11
  - 3.1. [Validations - Allow form to run validations in the field](#markdown-header-validations)
11
12
  - 3.1.1. [Named Validations](#markdown-header-validations)
12
13
  - 3.1.2. [Error Messages](#markdown-header-validations)
@@ -277,16 +278,18 @@ You can also specify the error messages you want.
277
278
  ```json
278
279
  {
279
280
  "validations": {
280
- "ON_FIELD_BLUR": {
281
- "require": true
282
- },
283
- "ON_FIELD_CHANGE": {
281
+ "methods": {
282
+ "require": true,
284
283
  "email": true
284
+ },
285
+ "eventMessages": {
286
+ "ON_FIELD_BLUR": ["required"],
287
+ "ON_FIELD_CHANGE": ["email"]
288
+ },
289
+ "messages": {
290
+ "default": "Default error message",
291
+ "email": "Invalid e-mail"
285
292
  }
286
- },
287
- "errorMessages": {
288
- "default": "Default error message",
289
- "email": "Invalid e-mail"
290
293
  }
291
294
  }
292
295
  ```
@@ -303,28 +306,29 @@ If you have a named validation, you can use its name in the error messages, havi
303
306
  ```json
304
307
  {
305
308
  "validations": {
306
- "ON_FIELD_BLUR": {
309
+ "methods": {
307
310
  "blurRequire": {
308
311
  "require": true
309
- }
310
- },
311
- "ON_FIELD_CHANGE": {
312
+ },
312
313
  "email": true,
313
314
  "changeRequire": {
314
315
  "require": true
315
316
  },
316
317
  "changeRestOfValidations": {
317
318
  "length": 50
318
- //...
319
319
  }
320
+ },
321
+ "eventMessages": {
322
+ "ON_FIELD_BLUR": ["blurRequire"],
323
+ "ON_FIELD_CHANGE": ["email", "changeRequire", "changeRestOfValidations"]
324
+ },
325
+ "messages": {
326
+ "default": "Default error message",
327
+ "email": "Invalid e-mail",
328
+ "blurRequire": "When you blur, this component is required",
329
+ "changeRequire": "You should not leave the field blank",
330
+ "changeRestOfValidations": "You are changing into an incorrect state"
320
331
  }
321
- },
322
- "errorMessages": {
323
- "default": "Default error message",
324
- "email": "Invalid e-mail",
325
- "blurRequire": "When you blur, this component is required",
326
- "changeRequire": "You should not leave the field blank",
327
- "changeRestOfValidations": "You are changing into an incorrect state"
328
332
  }
329
333
  }
330
334
  ```
@@ -624,10 +628,6 @@ Refer to the `TAvailableValidations` types here:
624
628
  * Allow to define a maximum length for the input to have no error
625
629
  */
626
630
  length?: number;
627
- /**
628
- * Will look into the input length and send an error if if not greater than this value
629
- */
630
- greaterThan?: number | string;
631
631
 
632
632
  /**
633
633
  * Specifies a regular expression pattern that the value should match.
@@ -669,7 +669,7 @@ Refer to the `TAvailableValidations` types here:
669
669
  * @param value - The value to be validated.
670
670
  * @returns An object with validation results.
671
671
  */
672
- callback?(value: string | number): { fail: boolean; errorMessage?: string };
672
+ callback?(value: string | number): boolean;
673
673
 
674
674
  /**
675
675
  * Specifies a numeric range for the value.
@@ -1371,14 +1371,17 @@ Templates are already a great power of form-engine, but we can go further allowi
1371
1371
  {
1372
1372
  "component": "input",
1373
1373
  "name": "password",
1374
- "errorMessages": {
1375
- "required": "Password is required",
1376
- "value": "Error value must be varOps.concatenate(${fields.email.value||0},${fields.email2.value||0})"
1377
- },
1378
1374
  "validations": {
1379
- "ON_FIELD_CHANGE": {
1375
+ "methods": {
1380
1376
  "required": true,
1381
1377
  "value": "varOps.concatenate(${fields.email.value||0},${fields.email2.value||0})"
1378
+ },
1379
+ "eventMessages": {
1380
+ "ON_FIELD_CHANGE": ["required", "value" ]
1381
+ },
1382
+ "messages": {
1383
+ "required": "Password is required",
1384
+ "value": "Error value must be varOps.concatenate(${fields.email.value||0},${fields.email2.value||0})"
1382
1385
  }
1383
1386
  },
1384
1387
  "props": {
@@ -1416,9 +1419,12 @@ Since we are already using [templates](#templates) to run our varOps and subscri
1416
1419
 
1417
1420
  ```json
1418
1421
  {
1419
- "errorMessages": {
1420
- "required": "Password is required",
1421
- "value": "Error value must be foo_bar"
1422
+ "validations": {
1423
+ ...,
1424
+ "messages": {
1425
+ "required": "Password is required",
1426
+ "value": "Error value must be foo_bar"
1427
+ }
1422
1428
  }
1423
1429
  }
1424
1430
  ```
@@ -1576,9 +1582,7 @@ Or Simply using the form reference in a button outside the form, for example:
1576
1582
  {
1577
1583
  const ref = useRef < TFormRefActions > null;
1578
1584
 
1579
- return (
1580
- <Form id="form" ref={ref} onClick={() => ref.current?.stepForward()} />
1581
- );
1585
+ return <Form id="form" ref={ref} onClick={() => ref.current?.stepForward()} />;
1582
1586
  }
1583
1587
 
1584
1588
  // --------------------- OR --------------------- //