@muziehdesign/forms 0.0.1-alpha.102

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.
@@ -0,0 +1,358 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, Input, NgModule } from '@angular/core';
3
+ import * as Yup from 'yup';
4
+ import { object } from 'yup';
5
+ import 'reflect-metadata';
6
+ import * as i1 from '@angular/common';
7
+ import { CommonModule } from '@angular/common';
8
+ import { __awaiter } from 'tslib';
9
+ import { BehaviorSubject, switchMap, from } from 'rxjs';
10
+
11
+ class ModelValidator {
12
+ constructor(modelSchema) {
13
+ this.schema = modelSchema;
14
+ }
15
+ validate(model) {
16
+ return this.schema
17
+ .validate(model, { abortEarly: false })
18
+ .then(() => {
19
+ return [];
20
+ })
21
+ .catch((e) => {
22
+ return e.inner.map((error) => ({ path: error.path, type: error.type, message: error.message }));
23
+ });
24
+ }
25
+ }
26
+
27
+ const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';
28
+
29
+ const METADATA_KEY = 'custom:muziehdesign:annotations';
30
+ var ConstraintType;
31
+ (function (ConstraintType) {
32
+ ConstraintType[ConstraintType["string"] = 0] = "string";
33
+ ConstraintType[ConstraintType["boolean"] = 1] = "boolean";
34
+ ConstraintType[ConstraintType["date"] = 2] = "date";
35
+ })(ConstraintType || (ConstraintType = {}));
36
+ const registerMetadata = (target, propertyKey, constraint) => {
37
+ const metadata = Reflect.getMetadata(METADATA_KEY, target) || new Map();
38
+ metadata.set(propertyKey, constraint);
39
+ Reflect.defineMetadata(METADATA_KEY, metadata, target);
40
+ };
41
+ function Annotate(a) {
42
+ return function (target, propertyKey) {
43
+ registerMetadata(target, propertyKey, a.annotations);
44
+ };
45
+ }
46
+ function StringType(...annotations) {
47
+ return function (target, propertyKey) {
48
+ const o = Object.assign({}, ...annotations);
49
+ o.constraintType = ConstraintType.string;
50
+ registerMetadata(target, propertyKey, o);
51
+ };
52
+ }
53
+ function BooleanType(...annotations) {
54
+ return function (target, propertyKey) {
55
+ const o = Object.assign({}, ...annotations);
56
+ o.constraintType = ConstraintType.boolean;
57
+ registerMetadata(target, propertyKey, o);
58
+ };
59
+ }
60
+ function required(message) {
61
+ return { required: { required: true, message: message } };
62
+ }
63
+ function pattern(regex, message) {
64
+ return { pattern: { pattern: regex, message: message } };
65
+ }
66
+ function length(length, message) {
67
+ return { length: { length: length, message: message } };
68
+ }
69
+ function maxLength(maxLength, message) {
70
+ return { maxLength: { maxLength: maxLength, message: message } };
71
+ }
72
+ function minLength(minLength, message) {
73
+ return { minLength: { minLength: minLength, message: message } };
74
+ }
75
+ function ofValues(values, message) {
76
+ return { ofValues: { values: values, message: message } };
77
+ }
78
+ function equals(value, message) {
79
+ return { equals: { equals: value, message: message } };
80
+ }
81
+ class AnnotationType {
82
+ }
83
+ class StringType2 extends AnnotationType {
84
+ constructor() {
85
+ super(...arguments);
86
+ this.name = 'StringType';
87
+ this.annotations = {
88
+ constraintType: ConstraintType.string, // TODO
89
+ };
90
+ }
91
+ required(message) {
92
+ this.annotations.required = { required: true, message: message };
93
+ return this;
94
+ }
95
+ pattern(pattern, message) {
96
+ this.annotations.pattern = { pattern: pattern, message: message };
97
+ return this;
98
+ }
99
+ }
100
+ class BooleanType2 extends AnnotationType {
101
+ constructor() {
102
+ super(...arguments);
103
+ this.name = 'BooleanType';
104
+ this.annotations = {
105
+ constraintType: ConstraintType.boolean, // TODO
106
+ };
107
+ }
108
+ required(message) {
109
+ this.annotations.required = { required: true, message: message };
110
+ return this;
111
+ }
112
+ equals(v, message) {
113
+ this.annotations.equals = { equals: v, message: message };
114
+ return this;
115
+ }
116
+ }
117
+ function string() {
118
+ return new StringType2();
119
+ }
120
+ function boolean() {
121
+ return new BooleanType2();
122
+ }
123
+ class DateType extends AnnotationType {
124
+ constructor() {
125
+ super(...arguments);
126
+ this.name = 'DateType';
127
+ this.annotations = {
128
+ constraintType: ConstraintType.date, // TODO
129
+ };
130
+ }
131
+ required(message) {
132
+ this.annotations.required = { required: true, message: message };
133
+ return this;
134
+ }
135
+ min(v, message) {
136
+ this.annotations.min = { min: v, message: message };
137
+ return this;
138
+ }
139
+ max(v, message) {
140
+ this.annotations.max = { max: v, message: message };
141
+ return this;
142
+ }
143
+ test(name, v, message) {
144
+ this.annotations.test = { name: name, test: v, message: message };
145
+ return this;
146
+ }
147
+ }
148
+ function date() {
149
+ return new DateType();
150
+ }
151
+
152
+ /*
153
+ Schema rules need to be built in the order they need to be evaluated in.
154
+ For example,
155
+ ```
156
+ schema.required().max(...).matches(...);
157
+ ```
158
+ evaluates the 3 rules in this order
159
+ - required
160
+ - max
161
+ - matches
162
+ */
163
+ class ModelSchemaFactory {
164
+ constructor() { }
165
+ build(model) {
166
+ const metadata = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);
167
+ let shape = {};
168
+ metadata.forEach((value, key) => {
169
+ if (value.constraintType == ConstraintType.string) {
170
+ shape[key] = this.buildStringSchema(value);
171
+ }
172
+ else if (value.constraintType == ConstraintType.boolean) {
173
+ shape[key] = this.buildBooleanSchema(value);
174
+ }
175
+ else if (value.constraintType == ConstraintType.date) {
176
+ shape[key] = this.buildDateSchema(value);
177
+ }
178
+ });
179
+ const schema = object(shape);
180
+ return new ModelValidator(schema);
181
+ }
182
+ buildStringSchema(options) {
183
+ let schema = Yup.string();
184
+ if (options.required) {
185
+ schema = schema.required(options.required.message);
186
+ }
187
+ if (options.length) {
188
+ schema = schema.length(options.length.length, options.length.message);
189
+ }
190
+ if (options.maxLength) {
191
+ schema = schema.max(options.maxLength.maxLength, options.maxLength.message);
192
+ }
193
+ if (options.minLength) {
194
+ schema = schema.min(options.minLength.minLength, options.minLength.message);
195
+ }
196
+ if (options.pattern) {
197
+ schema = schema.matches(options.pattern.pattern, options.pattern.message);
198
+ }
199
+ return schema;
200
+ }
201
+ buildBooleanSchema(options) {
202
+ let schema = Yup.boolean();
203
+ if (options.required) {
204
+ schema = schema.required(options.required.message);
205
+ }
206
+ if (options.equals) {
207
+ if (options.equals.equals) {
208
+ schema = schema.isTrue(options.equals.message);
209
+ }
210
+ else {
211
+ schema = schema.isFalse(options.equals.message);
212
+ }
213
+ }
214
+ return schema;
215
+ }
216
+ buildDateSchema(options) {
217
+ let schema = Yup.date();
218
+ if (options.required) {
219
+ schema = schema.required(options.required.message);
220
+ }
221
+ if (options.min) {
222
+ schema = schema.min(options.min.min, options.min.message);
223
+ }
224
+ if (options.max) {
225
+ schema = schema.max(options.max.max, options.max.message);
226
+ }
227
+ if (options.test) {
228
+ schema = schema.test({
229
+ name: options.test.name,
230
+ message: options.test.message,
231
+ test: (d, context) => {
232
+ return options.test.test(d);
233
+ }
234
+ });
235
+ }
236
+ return schema;
237
+ }
238
+ }
239
+ ModelSchemaFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: ModelSchemaFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
240
+ ModelSchemaFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: ModelSchemaFactory, providedIn: 'root' });
241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: ModelSchemaFactory, decorators: [{
242
+ type: Injectable,
243
+ args: [{
244
+ providedIn: 'root',
245
+ }]
246
+ }], ctorParameters: function () { return []; } });
247
+
248
+ class FieldErrorsComponent {
249
+ constructor() { }
250
+ ngOnInit() { }
251
+ }
252
+ FieldErrorsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: FieldErrorsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
253
+ FieldErrorsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.5", type: FieldErrorsComponent, selector: "mz-field-errors", inputs: { field: "field" }, ngImport: i0, template: "<div>\n field errors:\n {{ field?.errors | json }}\n</div>\n", styles: [""], dependencies: [{ kind: "pipe", type: i1.JsonPipe, name: "json" }] });
254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: FieldErrorsComponent, decorators: [{
255
+ type: Component,
256
+ args: [{ selector: 'mz-field-errors', template: "<div>\n field errors:\n {{ field?.errors | json }}\n</div>\n" }]
257
+ }], ctorParameters: function () { return []; }, propDecorators: { field: [{
258
+ type: Input
259
+ }] } });
260
+
261
+ class FormsModule {
262
+ }
263
+ FormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: FormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
264
+ FormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.5", ngImport: i0, type: FormsModule, declarations: [FieldErrorsComponent], imports: [CommonModule // TODO: can remove once done with temp error displaying
265
+ ], exports: [FieldErrorsComponent] });
266
+ FormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: FormsModule, imports: [CommonModule // TODO: can remove once done with temp error displaying
267
+ ] });
268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: FormsModule, decorators: [{
269
+ type: NgModule,
270
+ args: [{
271
+ providers: [],
272
+ declarations: [
273
+ FieldErrorsComponent
274
+ ],
275
+ exports: [
276
+ FieldErrorsComponent
277
+ ],
278
+ imports: [
279
+ CommonModule // TODO: can remove once done with temp error displaying
280
+ ]
281
+ }]
282
+ }] });
283
+
284
+ class NgFormModelStateFactory {
285
+ constructor(factory) {
286
+ this.factory = factory;
287
+ }
288
+ create(form, model, options) {
289
+ const modelState = new NgFormModelState(form, this.factory.build(model), model, options);
290
+ return modelState;
291
+ }
292
+ }
293
+ NgFormModelStateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable });
294
+ NgFormModelStateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' });
295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
296
+ type: Injectable,
297
+ args: [{
298
+ providedIn: 'root',
299
+ }]
300
+ }], ctorParameters: function () { return [{ type: ModelSchemaFactory }]; } });
301
+ class NgFormModelState {
302
+ constructor(form, modelValidator, model, options) {
303
+ this.form = form;
304
+ this.modelValidator = modelValidator;
305
+ this.model = model;
306
+ this.errors = new BehaviorSubject([]);
307
+ this.errors$ = this.errors.asObservable();
308
+ this.form.form.valueChanges
309
+ .pipe(switchMap((x) => __awaiter(this, void 0, void 0, function* () {
310
+ this.model = x;
311
+ return from(this.runValidations(options === null || options === void 0 ? void 0 : options.onValidate));
312
+ })))
313
+ .subscribe();
314
+ this.errors$.subscribe((list) => {
315
+ const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map());
316
+ grouped.forEach((value, key) => {
317
+ let validationErrors = {};
318
+ value.forEach((v) => (validationErrors[v.type] = v.message));
319
+ try {
320
+ this.form.controls[key].setErrors(validationErrors);
321
+ }
322
+ catch (e) {
323
+ console.log('error setting form control', key);
324
+ throw e;
325
+ }
326
+ });
327
+ });
328
+ }
329
+ isValid() {
330
+ return this.errors.value.length == 0;
331
+ }
332
+ setErrors(errors) {
333
+ this.errors.next(errors);
334
+ }
335
+ validate() {
336
+ return __awaiter(this, void 0, void 0, function* () {
337
+ return yield this.runValidations();
338
+ });
339
+ }
340
+ runValidations(callback) {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ const list = yield this.modelValidator.validate(this.model);
343
+ const final = (callback === null || callback === void 0 ? void 0 : callback(list)) || list;
344
+ this.errors.next(final);
345
+ });
346
+ }
347
+ }
348
+
349
+ /*
350
+ * Public API Surface of forms
351
+ */
352
+
353
+ /**
354
+ * Generated bundle index. Do not edit.
355
+ */
356
+
357
+ export { Annotate, AnnotationType, BooleanType, BooleanType2, ConstraintType, DateType, FieldErrorsComponent, FormsModule, ModelSchemaFactory, ModelValidator, NgFormModelState, NgFormModelStateFactory, StringType, StringType2, boolean, date, equals, length, maxLength, minLength, ofValues, pattern, required, string };
358
+ //# sourceMappingURL=muziehdesign-forms.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"muziehdesign-forms.mjs","sources":["../../../../projects/muziehdesign/forms/src/lib/model-validator.ts","../../../../projects/muziehdesign/forms/src/lib/constants.ts","../../../../projects/muziehdesign/forms/src/lib/type-annotations.ts","../../../../projects/muziehdesign/forms/src/lib/model-schema.factory.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.html","../../../../projects/muziehdesign/forms/src/lib/forms.module.ts","../../../../projects/muziehdesign/forms/src/lib/ng-form-model-state.service.ts","../../../../projects/muziehdesign/forms/src/public-api.ts","../../../../projects/muziehdesign/forms/src/muziehdesign-forms.ts"],"sourcesContent":["import { SchemaOf, ValidationError } from 'yup';\nimport { FieldError } from './field-error';\n\nexport class ModelValidator<T> {\n private schema: SchemaOf<T>;\n constructor(modelSchema: SchemaOf<T>) {\n this.schema = modelSchema;\n }\n\n validate<T>(model: T): Promise<FieldError[]> {\n return this.schema\n .validate(model, { abortEarly: false })\n .then(() => {\n return [];\n })\n .catch((e: ValidationError) => {\n return e.inner.map((error) => <FieldError>{ path: error.path, type: error.type, message: error.message });\n });\n }\n}\n","export const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';\n","import 'reflect-metadata';\n\nconst METADATA_KEY = 'custom:muziehdesign:annotations';\n\nexport enum ConstraintType {\n string,\n boolean,\n date,\n}\n\nexport interface ConstraintAnnotations {\n constraintType: ConstraintType;\n}\n\nexport interface StringTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n length?: LengthAnnotation;\n pattern?: PatternAnnotation;\n maxLength?: MaxLengthAnnotation;\n minLength?: MinLengthAnnotation;\n}\n\nexport interface BooleanTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n equals?: EqualsAnnotation<boolean>;\n}\n\nexport interface DateTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n min?: MinimumAnnotation<Date>;\n max?: MaximumAnnotation<Date>;\n test?: TestAnnotation;\n}\n\nexport interface ValidationAnnotation {\n message?: string;\n}\n\nexport interface RequiredAnnotation extends ValidationAnnotation {\n required: boolean;\n}\n\nexport interface LengthAnnotation extends ValidationAnnotation {\n length: number;\n}\n\nexport interface PatternAnnotation extends ValidationAnnotation {\n pattern: RegExp;\n}\n\nexport interface OfValuesAnnotation extends ValidationAnnotation {\n values: [];\n}\n\nexport interface EqualsAnnotation<T> extends ValidationAnnotation {\n equals: T;\n}\n\nexport interface MinimumAnnotation<T> extends ValidationAnnotation {\n min: T;\n}\n\nexport interface MaximumAnnotation<T> extends ValidationAnnotation {\n max: T;\n}\n\nexport interface TestAnnotation extends ValidationAnnotation {\n test: (d:Date) => boolean;\n name: string;\n}\n\nexport interface MaxLengthAnnotation extends ValidationAnnotation {\n maxLength: number;\n}\n\nexport interface MinLengthAnnotation extends ValidationAnnotation {\n minLength: number;\n}\n\nconst registerMetadata = (target: Object, propertyKey: string, constraint: ConstraintAnnotations) => {\n const metadata: Map<string, any> = Reflect.getMetadata(METADATA_KEY, target) || new Map<string, any>();\n metadata.set(propertyKey, constraint);\n Reflect.defineMetadata(METADATA_KEY, metadata, target);\n};\n\nexport function Annotate<T extends ConstraintAnnotations>(a: AnnotationType<T>) {\n return function (target: Object, propertyKey: string) {\n registerMetadata(target, propertyKey, a.annotations as ConstraintAnnotations);\n };\n}\n\nexport function StringType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as StringTypeAnnotations;\n o.constraintType = ConstraintType.string;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function BooleanType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as BooleanTypeAnnotations;\n o.constraintType = ConstraintType.boolean;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function required(message?: string): { [key: string]: RequiredAnnotation } {\n return { required: { required: true, message: message } };\n}\n\nexport function pattern(regex: RegExp, message?: string): { [key: string]: PatternAnnotation } {\n return { pattern: { pattern: regex, message: message } };\n}\n\nexport function length(length: number, message?: string): { [key: string]: LengthAnnotation } {\n return { length: { length: length, message: message } };\n}\n\nexport function maxLength(maxLength: number, message?: string): { [key: string]: MaxLengthAnnotation } {\n return { maxLength: { maxLength: maxLength, message: message } };\n}\n\nexport function minLength(minLength: number, message?: string): { [key: string]: MinLengthAnnotation } {\n return { minLength: { minLength: minLength, message: message } };\n}\n\nexport function ofValues(values: [], message?: string): { [key: string]: OfValuesAnnotation } {\n return { ofValues: { values: values, message: message } };\n}\n\nexport function equals<T>(value: T, message?: string): { [key: string]: EqualsAnnotation<T> } {\n return { equals: { equals: value, message: message } };\n}\n\nexport abstract class AnnotationType<T> {\n public abstract readonly name: string;\n public abstract annotations?: T;\n}\n\nexport class StringType2 extends AnnotationType<StringTypeAnnotations> {\n public readonly name: string = 'StringType';\n public annotations: StringTypeAnnotations = {\n constraintType: ConstraintType.string, // TODO\n };\n\n public required(message?: string) {\n this.annotations.required = { required: true, message: message };\n return this;\n }\n\n public pattern(pattern: RegExp, message?: string) {\n this.annotations.pattern = { pattern: pattern, message: message };\n return this;\n }\n}\n\nexport class BooleanType2 extends AnnotationType<BooleanTypeAnnotations> {\n public readonly name: string = 'BooleanType';\n public annotations: BooleanTypeAnnotations = {\n constraintType: ConstraintType.boolean, // TODO\n };\n\n public required(message?: string) {\n this.annotations.required = { required: true, message: message };\n return this;\n }\n\n public equals(v: boolean, message?: string) {\n this.annotations.equals = { equals: v, message: message };\n return this;\n }\n}\n\nexport function string() {\n return new StringType2();\n}\n\nexport function boolean() {\n return new BooleanType2();\n}\n\nexport class DateType extends AnnotationType<DateTypeAnnotations> {\n public readonly name: string = 'DateType';\n public annotations: DateTypeAnnotations = {\n constraintType: ConstraintType.date, // TODO\n };\n\n public required(message?: string) {\n this.annotations.required = { required: true, message: message };\n return this;\n }\n\n public min(v: Date, message?: string) {\n this.annotations.min = { min: v, message: message };\n return this;\n }\n\n public max(v: Date, message?: string) {\n this.annotations.max = { max: v, message: message };\n return this;\n }\n\n public test(name: string, v: (d: Date) => boolean, message?: string) {\n this.annotations.test = { name: name, test: v, message: message };\n return this;\n }\n}\n\nexport function date() {\n return new DateType();\n}\n","import { Injectable } from '@angular/core';\nimport { object, SchemaOf } from 'yup';\nimport { ModelValidator } from './model-validator';\nimport { SCHEMA_METADATA_NAMESPACE } from './constants';\nimport { ObjectShape } from 'yup/lib/object';\nimport { BooleanType, BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, StringType2, StringTypeAnnotations } from './type-annotations';\nimport * as Yup from 'yup';\n\n/*\nSchema rules need to be built in the order they need to be evaluated in.\nFor example,\n ```\n schema.required().max(...).matches(...);\n ```\nevaluates the 3 rules in this order\n - required\n - max\n - matches\n*/\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ModelSchemaFactory {\n constructor() {}\n\n build<T>(model: T): ModelValidator<T> {\n const metadata: Map<string, ConstraintAnnotations> = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);\n let shape: ObjectShape = {};\n metadata.forEach((value, key) => {\n if (value.constraintType == ConstraintType.string) {\n shape[key] = this.buildStringSchema(value as StringTypeAnnotations);\n } else if (value.constraintType == ConstraintType.boolean) {\n shape[key] = this.buildBooleanSchema(value as BooleanTypeAnnotations);\n } else if (value.constraintType == ConstraintType.date) {\n shape[key] = this.buildDateSchema(value as DateTypeAnnotations);\n }\n });\n const schema = object(shape) as SchemaOf<T>;\n return new ModelValidator(schema);\n }\n\n private buildStringSchema(options: StringTypeAnnotations) {\n let schema = Yup.string();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.length) {\n schema = schema.length(options.length.length, options.length.message);\n }\n\n if (options.maxLength) {\n schema = schema.max(options.maxLength.maxLength, options.maxLength.message);\n }\n\n if (options.minLength) {\n schema = schema.min(options.minLength.minLength, options.minLength.message);\n }\n\n if (options.pattern) {\n schema = schema.matches(options.pattern.pattern, options.pattern.message);\n }\n\n return schema;\n }\n\n private buildBooleanSchema(options: BooleanTypeAnnotations) {\n let schema = Yup.boolean();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.equals) {\n if (options.equals.equals) {\n schema = schema.isTrue(options.equals.message);\n } else {\n schema = schema.isFalse(options.equals.message);\n }\n }\n\n return schema;\n }\n\n private buildDateSchema(options: DateTypeAnnotations) {\n let schema = Yup.date();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.min) {\n schema = schema.min(options.min.min, options.min.message);\n }\n if (options.max) {\n schema = schema.max(options.max.max, options.max.message);\n }\n if (options.test) {\n schema = schema.test({\n name: options.test.name,\n message: options.test.message,\n test: (d?: Date, context?: any) => {\n return options.test!.test(d!);\n }});\n }\n\n return schema;\n }\n}\n","import { Component, Input, OnInit } from '@angular/core';\nimport { AbstractControl, NgControl, NgModel } from '@angular/forms';\n\n@Component({\n selector: 'mz-field-errors',\n templateUrl: './field-errors.component.html',\n styleUrls: ['./field-errors.component.css']\n})\nexport class FieldErrorsComponent implements OnInit {\n\n @Input() field?: NgControl;\n constructor() {}\n\n ngOnInit(): void { }\n\n}\n","<div>\n field errors:\n {{ field?.errors | json }}\n</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FieldErrorsComponent } from './field-errors/field-errors.component';\n\n\n\n@NgModule({\n providers: [],\n declarations: [\n FieldErrorsComponent\n ],\n exports: [\n FieldErrorsComponent\n ],\n imports: [\n CommonModule // TODO: can remove once done with temp error displaying\n ]\n})\nexport class FormsModule { }\n","import { Injectable, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { NgForm, ValidationErrors } from '@angular/forms';\nimport { BehaviorSubject, filter, from, switchMap } from 'rxjs';\nimport { FieldError } from './field-error';\nimport { ModelSchemaFactory } from './model-schema.factory';\nimport { ModelValidator } from './model-validator';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgFormModelStateFactory {\n constructor(private factory: ModelSchemaFactory) {}\n\n create<T>(form: NgForm, model: T, options?: ModelStateOptions) {\n const modelState = new NgFormModelState<T>(form, this.factory.build(model), model, options);\n return modelState;\n }\n}\n\nexport interface ModelStateOptions {\n onValidate: (errors: FieldError[]) => FieldError[]\n}\n\nexport class NgFormModelState<T> {\n private errors: BehaviorSubject<FieldError[]> = new BehaviorSubject<FieldError[]>([]);\n public errors$ = this.errors.asObservable();\n\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(options?.onValidate))\n })\n )\n .subscribe();\n\n this.errors$.subscribe((list) => {\n const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map<string, FieldError[]>());\n\n grouped.forEach((value, key) => {\n let validationErrors = <ValidationErrors>{};\n value.forEach((v) => (validationErrors[v.type] = v.message));\n try {\n this.form.controls[key].setErrors(validationErrors);\n } catch (e) {\n console.log('error setting form control', key);\n throw e;\n }\n });\n });\n }\n\n isValid(): boolean {\n return this.errors.value.length == 0;\n }\n\n setErrors(errors: FieldError[]) {\n this.errors.next(errors);\n }\n\n async validate(): Promise<void> {\n return await this.runValidations();\n }\n\n private async runValidations(callback?: (list:FieldError[])=>FieldError[]): Promise<void> {\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n}\n","/*\n * Public API Surface of forms\n */\nexport * from './lib/field-error';\nexport * from './lib/model-schema.factory';\nexport * from './lib/model-validator';\nexport * from './lib/type-annotations';\nexport * from './lib/forms.module';\nexport * from './lib/ng-form-model-state.service';\nexport * from './lib/field-errors/field-errors.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ModelSchemaFactory"],"mappings":";;;;;;;;;;MAGa,cAAc,CAAA;AAEzB,IAAA,WAAA,CAAY,WAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC3B;AAED,IAAA,QAAQ,CAAI,KAAQ,EAAA;QAClB,OAAO,IAAI,CAAC,MAAM;aACf,QAAQ,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aACtC,IAAI,CAAC,MAAK;AACT,YAAA,OAAO,EAAE,CAAC;AACZ,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,CAAkB,KAAI;AAC5B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,MAAiB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA,CAAC,CAAC;AAC5G,SAAC,CAAC,CAAC;KACN;AACF;;ACnBM,MAAM,yBAAyB,GAAG,iCAAiC;;ACE1E,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAE3C,IAAA,eAIX;AAJD,CAAA,UAAY,cAAc,EAAA;IACxB,cAAA,CAAA,cAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;IACN,cAAA,CAAA,cAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;IACP,cAAA,CAAA,cAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACN,CAAC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