Adds Formly

This commit is contained in:
Aaron Louie 2019-10-18 16:24:20 -04:00
parent e0caf50677
commit ccbeeec9f7
3 changed files with 30 additions and 0 deletions

16
package-lock.json generated
View File

@ -1730,6 +1730,22 @@
}
}
},
"@ngx-formly/core": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/@ngx-formly/core/-/core-5.5.1.tgz",
"integrity": "sha512-FmoDQNlwIEMj06D4iZCuV2Hk3kDAiDUsLyuIvWnn23z1Nk0GHcU/knhrYtodzJYwCPaGxiHAtHtxy5UlNOVOSg==",
"requires": {
"tslib": "^1.7.1"
}
},
"@ngx-formly/material": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/@ngx-formly/material/-/material-5.5.1.tgz",
"integrity": "sha512-5ka27YDCkfFSdkoH4oSBib57QsOwib8j3T0Jt/4c76kGR3YkOjaKyNVg/MLyKvSo23EizOCOMGNDNu7fPEBPpQ==",
"requires": {
"tslib": "^1.9.0"
}
},
"@schematics/angular": {
"version": "8.3.8",
"resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-8.3.8.tgz",

View File

@ -22,6 +22,8 @@
"@angular/platform-browser": "^8.2.9",
"@angular/platform-browser-dynamic": "^8.2.9",
"@angular/router": "^8.2.9",
"@ngx-formly/core": "^5.5.1",
"@ngx-formly/material": "^5.5.1",
"core-js": "^2.6.9",
"hammerjs": "^2.0.8",
"ng-inline-svg": "^9.1.0",

View File

@ -0,0 +1,12 @@
import { FormControl, ValidationErrors } from '@angular/forms';
import {FormlyFieldConfig} from '@ngx-formly/core';
export const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
export function EmailValidator(control: FormControl): ValidationErrors {
return EMAIL_REGEX.test(control.value) ? null : { 'email': true };
}
export function EmailValidatorMessage(err, field: FormlyFieldConfig) {
return `"${field.formControl.value}" is not a valid email address`;
}