By setting required to 'Yes'
By using default value
By defining validation rule
By using format
Answer is Right!
Answer is Wrong!
The correct answer is C. By defining validation rule.
A validation rule is a rule that specifies the valid values for a field. In this case, the validation rule would specify that the value of the field must be either 0 or 1.
The other options are not correct because:
- Option A: Setting required to ‘Yes’ would require that the field be filled in, but it would not limit the values that can be entered.
- Option B: Using default value would set a default value for the field, but it would not limit the values that can be entered.
- Option D: Using format would specify the format of the data that can be entered into the field, but it would not limit the values that can be entered.
Here is an example of a validation rule that would limit the value of the field ‘Sex’ to 0 and 1:
if(value != 0 && value != 1) {
throw new Error("Invalid value for field 'Sex'. The value must be either 0 or 1.");
}