@formspec/build 0.1.0-alpha.12 → 0.1.0-alpha.13

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/dist/browser.js CHANGED
@@ -66,11 +66,40 @@ function canonicalizeField(field) {
66
66
  }
67
67
  function canonicalizeTextField(field) {
68
68
  const type = { kind: "primitive", primitiveKind: "string" };
69
+ const constraints = [];
70
+ if (field.minLength !== void 0) {
71
+ const c = {
72
+ kind: "constraint",
73
+ constraintKind: "minLength",
74
+ value: field.minLength,
75
+ provenance: CHAIN_DSL_PROVENANCE
76
+ };
77
+ constraints.push(c);
78
+ }
79
+ if (field.maxLength !== void 0) {
80
+ const c = {
81
+ kind: "constraint",
82
+ constraintKind: "maxLength",
83
+ value: field.maxLength,
84
+ provenance: CHAIN_DSL_PROVENANCE
85
+ };
86
+ constraints.push(c);
87
+ }
88
+ if (field.pattern !== void 0) {
89
+ const c = {
90
+ kind: "constraint",
91
+ constraintKind: "pattern",
92
+ pattern: field.pattern,
93
+ provenance: CHAIN_DSL_PROVENANCE
94
+ };
95
+ constraints.push(c);
96
+ }
69
97
  return buildFieldNode(
70
98
  field.name,
71
99
  type,
72
100
  field.required,
73
- buildAnnotations(field.label, field.placeholder)
101
+ buildAnnotations(field.label, field.placeholder),
102
+ constraints
74
103
  );
75
104
  }
76
105
  function canonicalizeNumberField(field) {
@@ -94,6 +123,15 @@ function canonicalizeNumberField(field) {
94
123
  };
95
124
  constraints.push(c);
96
125
  }
126
+ if (field.multipleOf !== void 0) {
127
+ const c = {
128
+ kind: "constraint",
129
+ constraintKind: "multipleOf",
130
+ value: field.multipleOf,
131
+ provenance: CHAIN_DSL_PROVENANCE
132
+ };
133
+ constraints.push(c);
134
+ }
97
135
  return buildFieldNode(
98
136
  field.name,
99
137
  type,