@muziehdesign/forms 0.0.1-150
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/README.md +24 -0
- package/esm2020/lib/constants.mjs +2 -0
- package/esm2020/lib/field-error.mjs +2 -0
- package/esm2020/lib/field-errors/field-errors.component.mjs +18 -0
- package/esm2020/lib/forms.module.mjs +27 -0
- package/esm2020/lib/model-schema.factory.mjs +103 -0
- package/esm2020/lib/model-validator.mjs +16 -0
- package/esm2020/lib/ng-form-model-state.service.mjs +64 -0
- package/esm2020/lib/type-annotations.mjs +65 -0
- package/esm2020/muziehdesign-forms.mjs +5 -0
- package/esm2020/public-api.mjs +11 -0
- package/fesm2015/muziehdesign-forms.mjs +304 -0
- package/fesm2015/muziehdesign-forms.mjs.map +1 -0
- package/fesm2020/muziehdesign-forms.mjs +295 -0
- package/fesm2020/muziehdesign-forms.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/constants.d.ts +1 -0
- package/lib/field-error.d.ts +5 -0
- package/lib/field-errors/field-errors.component.d.ts +8 -0
- package/lib/forms.module.d.ts +8 -0
- package/lib/model-schema.factory.d.ts +11 -0
- package/lib/model-validator.d.ts +7 -0
- package/lib/ng-form-model-state.service.d.ts +29 -0
- package/lib/type-annotations.d.ts +99 -0
- package/package.json +31 -0
- package/public-api.d.ts +7 -0
|
@@ -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<Date>;\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<T> extends ValidationAnnotation {\n test: (d:T) => 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 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 DateType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as DateTypeAnnotations;\n o.constraintType = ConstraintType.date;\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 function min<T>(value: T, message?: string): { [key: string]: MinimumAnnotation<T> } {\n return { min: { min: value, message: message } };\n}\n\nexport function max<T>(value: T, message?: string): { [key: string]: MaximumAnnotation<T> } {\n return { max: { max: value, message: message } };\n}\n\nexport function test<T>(name: string, test: (d:T) => boolean, message?: string): { [key: string]: TestAnnotation<T> } {\n return { test: { name: name, test: test, message: message } };\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 { BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, 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().typeError('Please enter a valid 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 { NgControl, ValidationErrors } 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 {\n @Input() field?: NgControl;\n\n get errorMessage(): string {\n const errorKeys = Object.keys(this.field?.errors || {});\n return errorKeys.length > 0 ? (this.field?.errors as ValidationErrors)[errorKeys[0]] : '';\n }\n}\n","<div class=\"field-error\" *ngIf=\"errorMessage\">{{ errorMessage }}</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 private options?: ModelStateOptions;\n\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.options = options;\n \n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(this.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 this.form.controls[key]?.setErrors(validationErrors);\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(this.options?.onValidate);\n }\n\n private async runValidations(callback?: (list:FieldError[])=>FieldError[]): Promise<void> {\n this.removeCurrentErrors();\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n\n private removeCurrentErrors() {\n Object.keys(this.form.controls).forEach(key => this.form.controls[key].setErrors(null));\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;IAE3C,eAIX;AAJD,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,cAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;AACN,IAAA,cAAA,CAAA,cAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;AACP,IAAA,cAAA,CAAA,cAAA,CAAA,MAAA,CAAA,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AC5B,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC1B;AAED,IAAA,MAAM,QAAQ,GAAA;QACZ,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;KAC5D;IAEO,MAAM,cAAc,CAAC,QAA4C,EAAA;QACvE,IAAI,CAAC,mBAAmB,EAAE,CAAC;AAC3B,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5D,MAAM,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC;AACvC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACzB;IAEO,mBAAmB,GAAA;AACzB,QAAA,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KACzF;AACF;;ACzED;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SCHEMA_METADATA_NAMESPACE = "custom:muziehdesign:annotations";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NgControl } from '@angular/forms';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class FieldErrorsComponent {
|
|
4
|
+
field?: NgControl;
|
|
5
|
+
get errorMessage(): string;
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FieldErrorsComponent, never>;
|
|
7
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FieldErrorsComponent, "mz-field-errors", never, { "field": "field"; }, {}, never, never, false>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./field-errors/field-errors.component";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class FormsModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormsModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<FormsModule, [typeof i1.FieldErrorsComponent], [typeof i2.CommonModule], [typeof i1.FieldErrorsComponent]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<FormsModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelValidator } from './model-validator';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ModelSchemaFactory {
|
|
4
|
+
constructor();
|
|
5
|
+
build<T>(model: T): ModelValidator<T>;
|
|
6
|
+
private buildStringSchema;
|
|
7
|
+
private buildBooleanSchema;
|
|
8
|
+
private buildDateSchema;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ModelSchemaFactory, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ModelSchemaFactory>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NgForm } from '@angular/forms';
|
|
2
|
+
import { FieldError } from './field-error';
|
|
3
|
+
import { ModelSchemaFactory } from './model-schema.factory';
|
|
4
|
+
import { ModelValidator } from './model-validator';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class NgFormModelStateFactory {
|
|
7
|
+
private factory;
|
|
8
|
+
constructor(factory: ModelSchemaFactory);
|
|
9
|
+
create<T>(form: NgForm, model: T, options?: ModelStateOptions): NgFormModelState<T>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgFormModelStateFactory, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgFormModelStateFactory>;
|
|
12
|
+
}
|
|
13
|
+
export interface ModelStateOptions {
|
|
14
|
+
onValidate: (errors: FieldError[]) => FieldError[];
|
|
15
|
+
}
|
|
16
|
+
export declare class NgFormModelState<T> {
|
|
17
|
+
private form;
|
|
18
|
+
private modelValidator;
|
|
19
|
+
private model;
|
|
20
|
+
private errors;
|
|
21
|
+
errors$: import("rxjs").Observable<FieldError[]>;
|
|
22
|
+
private options?;
|
|
23
|
+
constructor(form: NgForm, modelValidator: ModelValidator<T>, model: T, options?: ModelStateOptions);
|
|
24
|
+
isValid(): boolean;
|
|
25
|
+
setErrors(errors: FieldError[]): void;
|
|
26
|
+
validate(): Promise<void>;
|
|
27
|
+
private runValidations;
|
|
28
|
+
private removeCurrentErrors;
|
|
29
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare enum ConstraintType {
|
|
3
|
+
string = 0,
|
|
4
|
+
boolean = 1,
|
|
5
|
+
date = 2
|
|
6
|
+
}
|
|
7
|
+
export interface ConstraintAnnotations {
|
|
8
|
+
constraintType: ConstraintType;
|
|
9
|
+
}
|
|
10
|
+
export interface StringTypeAnnotations extends ConstraintAnnotations {
|
|
11
|
+
required?: RequiredAnnotation;
|
|
12
|
+
length?: LengthAnnotation;
|
|
13
|
+
pattern?: PatternAnnotation;
|
|
14
|
+
maxLength?: MaxLengthAnnotation;
|
|
15
|
+
minLength?: MinLengthAnnotation;
|
|
16
|
+
}
|
|
17
|
+
export interface BooleanTypeAnnotations extends ConstraintAnnotations {
|
|
18
|
+
required?: RequiredAnnotation;
|
|
19
|
+
equals?: EqualsAnnotation<boolean>;
|
|
20
|
+
}
|
|
21
|
+
export interface DateTypeAnnotations extends ConstraintAnnotations {
|
|
22
|
+
required?: RequiredAnnotation;
|
|
23
|
+
min?: MinimumAnnotation<Date>;
|
|
24
|
+
max?: MaximumAnnotation<Date>;
|
|
25
|
+
test?: TestAnnotation<Date>;
|
|
26
|
+
}
|
|
27
|
+
export interface ValidationAnnotation {
|
|
28
|
+
message?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface RequiredAnnotation extends ValidationAnnotation {
|
|
31
|
+
required: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface LengthAnnotation extends ValidationAnnotation {
|
|
34
|
+
length: number;
|
|
35
|
+
}
|
|
36
|
+
export interface PatternAnnotation extends ValidationAnnotation {
|
|
37
|
+
pattern: RegExp;
|
|
38
|
+
}
|
|
39
|
+
export interface OfValuesAnnotation extends ValidationAnnotation {
|
|
40
|
+
values: [];
|
|
41
|
+
}
|
|
42
|
+
export interface EqualsAnnotation<T> extends ValidationAnnotation {
|
|
43
|
+
equals: T;
|
|
44
|
+
}
|
|
45
|
+
export interface MinimumAnnotation<T> extends ValidationAnnotation {
|
|
46
|
+
min: T;
|
|
47
|
+
}
|
|
48
|
+
export interface MaximumAnnotation<T> extends ValidationAnnotation {
|
|
49
|
+
max: T;
|
|
50
|
+
}
|
|
51
|
+
export interface TestAnnotation<T> extends ValidationAnnotation {
|
|
52
|
+
test: (d: T) => boolean;
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
export interface MaxLengthAnnotation extends ValidationAnnotation {
|
|
56
|
+
maxLength: number;
|
|
57
|
+
}
|
|
58
|
+
export interface MinLengthAnnotation extends ValidationAnnotation {
|
|
59
|
+
minLength: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function StringType(...annotations: {
|
|
62
|
+
[key: string]: ValidationAnnotation;
|
|
63
|
+
}[]): (target: Object, propertyKey: string) => void;
|
|
64
|
+
export declare function BooleanType(...annotations: {
|
|
65
|
+
[key: string]: ValidationAnnotation;
|
|
66
|
+
}[]): (target: Object, propertyKey: string) => void;
|
|
67
|
+
export declare function DateType(...annotations: {
|
|
68
|
+
[key: string]: ValidationAnnotation;
|
|
69
|
+
}[]): (target: Object, propertyKey: string) => void;
|
|
70
|
+
export declare function required(message?: string): {
|
|
71
|
+
[key: string]: RequiredAnnotation;
|
|
72
|
+
};
|
|
73
|
+
export declare function pattern(regex: RegExp, message?: string): {
|
|
74
|
+
[key: string]: PatternAnnotation;
|
|
75
|
+
};
|
|
76
|
+
export declare function length(length: number, message?: string): {
|
|
77
|
+
[key: string]: LengthAnnotation;
|
|
78
|
+
};
|
|
79
|
+
export declare function maxLength(maxLength: number, message?: string): {
|
|
80
|
+
[key: string]: MaxLengthAnnotation;
|
|
81
|
+
};
|
|
82
|
+
export declare function minLength(minLength: number, message?: string): {
|
|
83
|
+
[key: string]: MinLengthAnnotation;
|
|
84
|
+
};
|
|
85
|
+
export declare function ofValues(values: [], message?: string): {
|
|
86
|
+
[key: string]: OfValuesAnnotation;
|
|
87
|
+
};
|
|
88
|
+
export declare function equals<T>(value: T, message?: string): {
|
|
89
|
+
[key: string]: EqualsAnnotation<T>;
|
|
90
|
+
};
|
|
91
|
+
export declare function min<T>(value: T, message?: string): {
|
|
92
|
+
[key: string]: MinimumAnnotation<T>;
|
|
93
|
+
};
|
|
94
|
+
export declare function max<T>(value: T, message?: string): {
|
|
95
|
+
[key: string]: MaximumAnnotation<T>;
|
|
96
|
+
};
|
|
97
|
+
export declare function test<T>(name: string, test: (d: T) => boolean, message?: string): {
|
|
98
|
+
[key: string]: TestAnnotation<T>;
|
|
99
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@muziehdesign/forms",
|
|
3
|
+
"version": "0.0.1-150",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^14.0.0",
|
|
6
|
+
"@angular/core": "^14.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"module": "fesm2015/muziehdesign-forms.mjs",
|
|
12
|
+
"es2020": "fesm2020/muziehdesign-forms.mjs",
|
|
13
|
+
"esm2020": "esm2020/muziehdesign-forms.mjs",
|
|
14
|
+
"fesm2020": "fesm2020/muziehdesign-forms.mjs",
|
|
15
|
+
"fesm2015": "fesm2015/muziehdesign-forms.mjs",
|
|
16
|
+
"typings": "index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": {
|
|
19
|
+
"default": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"esm2020": "./esm2020/muziehdesign-forms.mjs",
|
|
24
|
+
"es2020": "./fesm2020/muziehdesign-forms.mjs",
|
|
25
|
+
"es2015": "./fesm2015/muziehdesign-forms.mjs",
|
|
26
|
+
"node": "./fesm2015/muziehdesign-forms.mjs",
|
|
27
|
+
"default": "./fesm2020/muziehdesign-forms.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": false
|
|
31
|
+
}
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './lib/field-error';
|
|
2
|
+
export * from './lib/model-schema.factory';
|
|
3
|
+
export * from './lib/model-validator';
|
|
4
|
+
export * from './lib/type-annotations';
|
|
5
|
+
export * from './lib/forms.module';
|
|
6
|
+
export * from './lib/ng-form-model-state.service';
|
|
7
|
+
export * from './lib/field-errors/field-errors.component';
|