Latest version of Angular is 4.4.3.
In Reactive Form, you can use Validators.required
for each form field as shown below:
this.loginForm = this.fb.group({
firstName: ['', [Validators.required, Validators.maxLength(55)]],
lastName: ['', Validators.required],
age: [1, Validators.required],
email: ['', Validators.required],
username: ['', Validators.required],
gender: ['', Validators.required],
address: this.fb.group({
city: ['', Validators.required],
country: ['', Validators.required]
})
});
It is necessary to include Validators.required
for every form field.
I am searching for a solution or method in the Angular FormBuilder/FormControl that would set all fields as required and allow additional validators to be added if needed.