sslibs-regex-validation
v0.0.5
Published
## Installation
Downloads
4
Readme
RegexValidation
Installation
npm i sslibs-regex-validation
Example
import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import {
ValidationGroup,
getValidationErrorString,
confirmPasswordValidator,
addRequired,
FormValidator,
validatorFocus
} from 'sslibs-regex-validation';
@Component({
selector: 'app-password-reset-page',
templateUrl: './password-reset-page.component.html',
styleUrls: [ './password-reset-page.component.scss' ]
})
export class PasswordResetPageComponent extends FormValidator
implements OnInit {
public errorString?: string;
constructor(
private formBuilder: FormBuilder,
private handler: HandlerService
) {
super();
}
ngOnInit() {
this.createForm();
}
createForm() {
this.form = this.formBuilder.group(
{
email: [ '', addRequired(ValidationGroup.email) ],
password: [ '', ValidationGroup.password ],
confirmPassword: [ '', [ Validators.required ] ]
},
{ validator: confirmPasswordValidator }
);
}
onSubmit() {
this.hasSubmit = true;
if (this.form.invalid) {
this.isValid = false;
validatorFocus();
return;
}
else {
const data = this.form.getRawValue();
// TODO: Send data to server
}
}
}