@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.
@@ -117,11 +117,40 @@ function canonicalizeField(field) {
117
117
  }
118
118
  function canonicalizeTextField(field) {
119
119
  const type = { kind: "primitive", primitiveKind: "string" };
120
+ const constraints = [];
121
+ if (field.minLength !== void 0) {
122
+ const c = {
123
+ kind: "constraint",
124
+ constraintKind: "minLength",
125
+ value: field.minLength,
126
+ provenance: CHAIN_DSL_PROVENANCE
127
+ };
128
+ constraints.push(c);
129
+ }
130
+ if (field.maxLength !== void 0) {
131
+ const c = {
132
+ kind: "constraint",
133
+ constraintKind: "maxLength",
134
+ value: field.maxLength,
135
+ provenance: CHAIN_DSL_PROVENANCE
136
+ };
137
+ constraints.push(c);
138
+ }
139
+ if (field.pattern !== void 0) {
140
+ const c = {
141
+ kind: "constraint",
142
+ constraintKind: "pattern",
143
+ pattern: field.pattern,
144
+ provenance: CHAIN_DSL_PROVENANCE
145
+ };
146
+ constraints.push(c);
147
+ }
120
148
  return buildFieldNode(
121
149
  field.name,
122
150
  type,
123
151
  field.required,
124
- buildAnnotations(field.label, field.placeholder)
152
+ buildAnnotations(field.label, field.placeholder),
153
+ constraints
125
154
  );
126
155
  }
127
156
  function canonicalizeNumberField(field) {
@@ -145,6 +174,15 @@ function canonicalizeNumberField(field) {
145
174
  };
146
175
  constraints.push(c);
147
176
  }
177
+ if (field.multipleOf !== void 0) {
178
+ const c = {
179
+ kind: "constraint",
180
+ constraintKind: "multipleOf",
181
+ value: field.multipleOf,
182
+ provenance: CHAIN_DSL_PROVENANCE
183
+ };
184
+ constraints.push(c);
185
+ }
148
186
  return buildFieldNode(
149
187
  field.name,
150
188
  type,