All files / app/forms register.form.ts

100% Statements 53/53
100% Branches 2/2
100% Functions 2/2
100% Lines 53/53

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 541x 1x 1x 1x 1x 1x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 1x 1x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 988x 1x  
import { BaseForm } from './base.form';
import { FormGroup, Validators } from '@angular/forms';
import { GlobalValidator } from '../validators/global.validator';
 
export class RegisterForm extends BaseForm {
	getFieldsConfig(): FormGroup {
		return this.formBuilder.group({
			first_name: ['', Validators.compose([GlobalValidator.letter, Validators.required])],
			last_name: ['', Validators.compose([Validators.required, GlobalValidator.letter])],
			phone: [
				'',
				Validators.compose([
					// Validators.required,
					GlobalValidator.phoneFormat,
				]),
			],
			email: ['', Validators.compose([Validators.required, GlobalValidator.mailFormat])],
			password: ['', Validators.compose([GlobalValidator.passwordsLength, Validators.required])],
			password_again: ['', Validators.compose([GlobalValidator.passwordsMatch, Validators.required])],
		});
	}
 
	getValidationMessages(): any {
		return {
			first_name: {
				required: 'Name is required',
				pattern: 'Only letter characters are allowed',
			},
			last_name: {
				required: 'Surname is required',
				pattern: 'Only letter characters are allowed',
			},
			phone: {
				// 'required': 'Phone is required',
				phone_invalid: 'Phone number is not valid',
			},
			email: {
				required: 'Email address is required',
				invalid: 'Email address is not valid',
				taken: 'Email address is already taken',
				EmailIsIncorrect: 'Email address is not valid',
			},
			password: {
				required: 'Password is required',
				too_short: 'Password is too short',
			},
			password_again: {
				required: 'Password check is required',
				passwords_not_match: 'Password not match',
			},
		};
	}
}