40.4k views
2 votes
Which example sets a constraint to validate user input?

A: The name field disallows numbers.
B: The email field accepts only numbers.
C: The address field should be less than 30 characters.
D: The zip code accepts letters.
E: The phone number accepts letters."

User Tiddly
by
7.2k points

1 Answer

5 votes

Final answer:

Option C: The correct example of a constraint for validating user input is C, where the address field is restricted to less than 30 characters. This limits input length, which is a common form of validation.

Step-by-step explanation:

The example that sets a constraint to validate user input is: C: The address field should be less than 30 characters. This is a typical form of input validation where the length of the input is restricted to ensure data fits within a predefined storage size or to meet certain usability standards. For instance, databases may allocate only limited character space for certain fields, making this validation essential.

Option A may also be considered a constraint, as it disallows numbers in the name field which is sensible since names typically consist of alphabetic characters. However, the limitation based on characters rather than length or format is more of a pattern restriction. The other examples B, D, and E suggest improper validation since email fields should not only accept numbers, zip codes typically do not include letters (depending on the country), and phone numbers should generally not accept letters.

User Jesse Hall
by
7.2k points