B. The render prop destructuring is incorrect; should destructure field object
C. The control prop is missing
D. The minLength rule should be a string, not a number
Solution
Step 1: Check render prop destructuring
The render function receives an object with a field property, which contains onChange and value. Direct destructuring of onChange and value is incorrect.
Step 2: Verify other props
The minLength rule accepts a number, control is present, and name is correctly placed.
Final Answer:
The render prop destructuring is incorrect; should destructure field object -> Option B
Quick Check:
Render prop needs field destructuring = D [OK]
Hint: Destructure { field: { onChange, value } } in render prop [OK]
Common Mistakes:
Destructuring onChange and value directly from render argument
Using string instead of number for minLength
Omitting control or name props
5. You want to create a React Native form with two fields: username and age. The age must be a number greater than 18. Using React Hook Form, which validation rule correctly enforces this for age?
hard
A. rules={{ required: true, min: 19, valueAsNumber: true }}
B. rules={{ required: true, minLength: 18 }}
C. rules={{ required: true, validate: value => value > 18 }}
D. rules={{ required: true, max: 18 }}
Solution
Step 1: Numeric validation from string input
TextInput provides strings; valueAsNumber: true in rules parses to number for validation.
Step 2: Rule for >18
min: 19 ensures parsed number >= 19 (>18).
Step 3: Eliminate others
A's validate on string fails ("100" < "18" lexically). B for strings. D opposite.