forked from udos86/ng-dynamic-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
61 lines (59 loc) · 2.23 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { bootstrapApplication } from "@angular/platform-browser";
import { enableProdMode } from "@angular/core";
import { LocationStrategy, HashLocationStrategy } from "@angular/common";
import { AppComponent } from "./app/app.component";
import { withInterceptorsFromDi, provideHttpClient } from "@angular/common/http";
import { provideAnimations } from "@angular/platform-browser/animations";
import { NG_VALIDATORS, NG_ASYNC_VALIDATORS } from "@angular/forms";
import { provideRouter } from "@angular/router";
import { MAT_CHIPS_DEFAULT_OPTIONS } from "@angular/material/chips";
import { DYNAMIC_VALIDATORS, Validator, ValidatorFactory, DYNAMIC_MATCHER_PROVIDERS } from "@ng-dynamic-forms/core";
import { appRoutes } from "./app/app.routes";
import { customValidator, customDateRangeValidator, customAsyncValidator, customForbiddenValidator } from "./app/app.validators";
import { environment } from "./environments/environment";
if (environment.production) {
enableProdMode();
}
bootstrapApplication(AppComponent, {
providers: [
provideRouter(appRoutes),
provideAnimations(),
provideHttpClient(withInterceptorsFromDi()),
{
provide: LocationStrategy,
useClass: HashLocationStrategy
},
{
provide: NG_VALIDATORS,
useValue: customValidator,
multi: true
},
{
provide: NG_VALIDATORS,
useValue: customDateRangeValidator,
multi: true
},
{
provide: NG_ASYNC_VALIDATORS,
useValue: customAsyncValidator,
multi: true
},
{
provide: DYNAMIC_VALIDATORS,
useValue: new Map<string, Validator | ValidatorFactory>([
["customValidator", customValidator],
["customDateRangeValidator", customDateRangeValidator],
["customForbiddenValidator", customForbiddenValidator],
["customAsyncValidator", customAsyncValidator]
])
},
...DYNAMIC_MATCHER_PROVIDERS,
{
provide: MAT_CHIPS_DEFAULT_OPTIONS,
useValue: {
separatorKeyCodes: [13, 188]
}
}
]
})
.catch(err => console.error(err));