unischema 1.1.0 → 1.2.0

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 (65) hide show
  1. package/README.md +151 -2
  2. package/dist/adapters/backend/index.d.mts +2 -2
  3. package/dist/adapters/backend/index.d.ts +2 -2
  4. package/dist/adapters/backend/index.js +11 -11
  5. package/dist/adapters/backend/index.mjs +8 -8
  6. package/dist/adapters/frontend/index.d.mts +2 -2
  7. package/dist/adapters/frontend/index.d.ts +2 -2
  8. package/dist/adapters/frontend/index.js +10 -10
  9. package/dist/adapters/frontend/index.mjs +8 -8
  10. package/dist/{chunk-XGTUU27F.mjs → chunk-5A4ITJVD.mjs} +1 -1
  11. package/dist/{chunk-ASKTY6EG.js → chunk-66RFUBVU.js} +20 -20
  12. package/dist/{chunk-KHHJD6QK.mjs → chunk-75YSYC4K.mjs} +1 -1
  13. package/dist/{chunk-BNIB23NQ.js → chunk-76BBWQDH.js} +13 -13
  14. package/dist/{chunk-ELL7U7IC.mjs → chunk-7XES4A3M.mjs} +1 -1
  15. package/dist/{chunk-FRBZHN4K.mjs → chunk-COMVAVFU.mjs} +1 -1
  16. package/dist/chunk-DT2TQZU7.js +796 -0
  17. package/dist/{chunk-2JYFKT3R.js → chunk-FPCCH55A.js} +14 -14
  18. package/dist/{chunk-3FANCMEF.js → chunk-IUXRLMET.js} +34 -34
  19. package/dist/{chunk-CQYXR2LZ.js → chunk-JEW6U6CB.js} +65 -65
  20. package/dist/{chunk-XC4DKEXP.mjs → chunk-KZCV5IW4.mjs} +1 -1
  21. package/dist/{chunk-FKDWSZIV.mjs → chunk-KZZ7NVU3.mjs} +4 -2
  22. package/dist/{chunk-3TS35CVJ.mjs → chunk-MFEBMQAU.mjs} +341 -40
  23. package/dist/{chunk-NUW55QTO.js → chunk-OIYG5D2I.js} +4 -2
  24. package/dist/{chunk-VWP24NYS.mjs → chunk-RW6HDA5H.mjs} +1 -1
  25. package/dist/{chunk-FZ7K2PC7.js → chunk-TXT36BCE.js} +35 -35
  26. package/dist/index-C17xs-fU.d.mts +140 -0
  27. package/dist/index-C17xs-fU.d.ts +140 -0
  28. package/dist/index.d.mts +26 -8
  29. package/dist/index.d.ts +26 -8
  30. package/dist/index.js +262 -25
  31. package/dist/index.mjs +228 -14
  32. package/dist/{schema-DYU1zGVm.d.mts → schema-DYE8Wz8X.d.mts} +84 -2
  33. package/dist/{schema-CpAjXgEF.d.ts → schema-Dtp-joeT.d.ts} +84 -2
  34. package/dist/validators/array.d.mts +1 -1
  35. package/dist/validators/array.d.ts +1 -1
  36. package/dist/validators/array.js +8 -8
  37. package/dist/validators/array.mjs +2 -2
  38. package/dist/validators/common.d.mts +1 -1
  39. package/dist/validators/common.d.ts +1 -1
  40. package/dist/validators/common.js +7 -7
  41. package/dist/validators/common.mjs +2 -2
  42. package/dist/validators/date.d.mts +1 -1
  43. package/dist/validators/date.d.ts +1 -1
  44. package/dist/validators/date.js +12 -12
  45. package/dist/validators/date.mjs +2 -2
  46. package/dist/validators/index.d.mts +2 -2
  47. package/dist/validators/index.d.ts +2 -2
  48. package/dist/validators/index.js +68 -68
  49. package/dist/validators/index.mjs +7 -7
  50. package/dist/validators/number.d.mts +1 -1
  51. package/dist/validators/number.d.ts +1 -1
  52. package/dist/validators/number.js +13 -13
  53. package/dist/validators/number.mjs +2 -2
  54. package/dist/validators/object.d.mts +1 -1
  55. package/dist/validators/object.d.ts +1 -1
  56. package/dist/validators/object.js +6 -6
  57. package/dist/validators/object.mjs +2 -2
  58. package/dist/validators/string.d.mts +1 -1
  59. package/dist/validators/string.d.ts +1 -1
  60. package/dist/validators/string.js +19 -19
  61. package/dist/validators/string.mjs +2 -2
  62. package/package.json +47 -5
  63. package/dist/chunk-BJLVOIAP.js +0 -491
  64. package/dist/index-BQR7OrY7.d.mts +0 -80
  65. package/dist/index-BQR7OrY7.d.ts +0 -80
@@ -1,80 +0,0 @@
1
- /**
2
- * Core types for the FormSchema validation engine
3
- */
4
- type ValidationSeverity = 'hard' | 'soft';
5
- interface ValidationError {
6
- /** Field path (e.g., "email" or "address.city") */
7
- field: string;
8
- /** Error code for programmatic handling */
9
- code: string;
10
- /** Human-readable error message */
11
- message: string;
12
- /** Severity level - hard errors block submission, soft are warnings */
13
- severity: ValidationSeverity;
14
- }
15
- interface ValidationResult {
16
- /** True if no hard errors exist */
17
- valid: boolean;
18
- /** Errors that block form submission */
19
- hardErrors: ValidationError[];
20
- /** Warnings that don't block submission */
21
- softErrors: ValidationError[];
22
- }
23
- type FieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
24
- interface ValidationRule {
25
- /** Rule type identifier */
26
- type: string;
27
- /** Rule parameters */
28
- params?: Record<string, unknown>;
29
- /** Custom error message */
30
- message?: string;
31
- /** Is this a soft validation (warning only)? */
32
- soft?: boolean;
33
- }
34
- interface FieldDefinition<T = unknown> {
35
- /** The base type of this field */
36
- type: FieldType;
37
- /** Validation rules to apply */
38
- rules: ValidationRule[];
39
- /** Is this field required? */
40
- required: boolean;
41
- /** Default value */
42
- defaultValue?: T;
43
- /** For nested schemas */
44
- schema?: SchemaDefinition;
45
- /** For array items */
46
- items?: FieldDefinition;
47
- /** Field metadata */
48
- meta?: Record<string, unknown>;
49
- }
50
- interface SchemaDefinition {
51
- /** Field definitions keyed by field name */
52
- fields: Record<string, FieldDefinition>;
53
- /** Schema metadata */
54
- meta?: Record<string, unknown>;
55
- }
56
- interface ValidatorContext {
57
- /** Current field path */
58
- path: string;
59
- /** Full data object being validated */
60
- root: unknown;
61
- /** Parent object containing this field */
62
- parent?: unknown;
63
- }
64
- type ValidatorFn = (value: unknown, params: Record<string, unknown> | undefined, context: ValidatorContext) => ValidationError | null;
65
- interface EnterpriseValidationResponse {
66
- status: 'success' | 'validation_error';
67
- data?: unknown;
68
- errors: ValidationError[];
69
- msg: string;
70
- validation: {
71
- hard_validations: ValidationError[];
72
- soft_validations: ValidationError[];
73
- };
74
- }
75
- /**
76
- * Convert ValidationResult to enterprise-compatible response format
77
- */
78
- declare function toEnterpriseResponse(result: ValidationResult, data?: unknown): EnterpriseValidationResponse;
79
-
80
- export { type EnterpriseValidationResponse as E, type FieldType as F, type SchemaDefinition as S, type ValidatorContext as V, type ValidationError as a, type ValidationResult as b, type ValidatorFn as c, type ValidationSeverity as d, type ValidationRule as e, type FieldDefinition as f, toEnterpriseResponse as t };