bank20baht-validator 0.3.0 → 0.3.2

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 (2) hide show
  1. package/dist/index.js +6 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  // every value must have the shape the UI control could actually emit before
14
14
  // the authored validators run.
15
15
  // ---------------------------------------------------------------------------
16
- import { applyFlags, approvalFields, createScriptContext, defaultValue, evaluate, hasScripts, runScripts, getCatalog, parseDisabledEntry, parseIsoDate, resolveViewFields, setCatalog, setLocale, t, validateField, walkPath, normalizeLegacySchema, } from 'bank20baht-ui/engine';
16
+ import { applyFlags, approvalFields, createScriptContext, defaultValue, evaluate, hasScripts, runScripts, getCatalog, parseDisabledEntry, parseIsoDate, parseIsoDateTime, resolveViewFields, setCatalog, setLocale, t, validateField, walkPath, normalizeLegacySchema, } from 'bank20baht-ui/engine';
17
17
  /**
18
18
  * Run `fn` with the catalog switched to `locale`, restoring the previous
19
19
  * catalog after. The engine catalog is module-global; validation is fully
@@ -39,6 +39,7 @@ const FIELD_TYPES = new Set([
39
39
  'text',
40
40
  'textarea',
41
41
  'number',
42
+ 'currency',
42
43
  'email',
43
44
  'password',
44
45
  'dropdown',
@@ -92,8 +93,9 @@ function typeIssue(field, value) {
92
93
  case 'password':
93
94
  return typeof value === 'string' ? null : t('pattern');
94
95
  case 'date': {
95
- // value shape follows date_mode; every day must be a real ISO calendar day
96
- const isDay = (v) => parseIsoDate(v) !== null;
96
+ // value shape follows date_mode; every entry must be a real ISO calendar
97
+ // day, or an ISO local datetime when the field carries `enable_time`
98
+ const isDay = (v) => field.enable_time ? parseIsoDateTime(v) !== null : parseIsoDate(v) !== null;
97
99
  switch (field.date_mode ?? 'single') {
98
100
  case 'range':
99
101
  return Array.isArray(value) && value.length === 2 && value.every(isDay)
@@ -106,6 +108,7 @@ function typeIssue(field, value) {
106
108
  }
107
109
  }
108
110
  case 'number':
111
+ case 'currency':
109
112
  return typeof value === 'number' && Number.isFinite(value) ? null : t('pattern');
110
113
  case 'checkbox':
111
114
  case 'toggle':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bank20baht-validator",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Runtime validation for bahtui form/workflow JSON — the exact engine rules the client runs, on the server.",
6
6
  "license": "MIT",