Loading

Quipoin Menu

Learn • Practice • Grow

angular / Reactive Form Validation
mcq
Direction: Choose the correct option

Q1.

How do you set validators on a `FormControl` programmatically?
A. `control.addValidator(...)`
B. `control.setValidators([Validators.required])`
C. `control.setValidator(...)`
D. `control.validators = [...]`
Direction: Choose the correct option

Q2.

What does `control.updateValueAndValidity()` do?
A. Recalculates the value and validation status
B. Updates the control's value
C. Triggers change detection
D. Resets validation
Direction: Choose the correct option

Q3.

How do you get the error object for a specific validator?
A. `control.error('required')`
B. Both A and B
C. `control.errors.required`
D. `control.getError('required')`
Direction: Choose the correct option

Q4.

What is cross-field validation?
A. Validation that involves multiple form controls
B. Validation across modules
C. Validation across forms
D. Validation across routes
Direction: Choose the correct option

Q5.

Where do you define cross-field validators?
A. In the template
B. In a separate service
C. At the `FormGroup` level
D. At the `FormControl` level
Direction: Choose the correct option

Q6.

How do you clear validators from a control?
A. `control.validators = []`
B. Both B and C
C. `control.clearValidators()`
D. `control.setValidators(null)`
Direction: Choose the correct option

Q7.

What is the `valid` property of a form control?
A. Boolean indicating if the control has no validation errors
B. Value is valid
C. Control is valid
D. Valid state
Direction: Choose the correct option

Q8.

What does the `invalid` property represent?
A. Opposite of valid
B. False if valid
C. All of the above
D. True if at least one validation error exists
Direction: Choose the correct option

Q9.

What is the `pending` property used for?
A. Async state
B. Waiting for validation
C. Control is pending
D. Indicates that async validation is in progress
Direction: Choose the correct option

Q10.

How do you disable a form control programmatically?
A. `control.disable()`
B. `control.disabled = true`
C. `control.enable(false)`
D. `control.setDisabled(true)`