Validation techniques Flashcards

1
Q

In her source code, Cerie must perform three validation techniques on a specific input. What sequence should she follow, and what’s the reasoning behind it?

A

Cerie should prioritize the existence check, followed by the type check and then the range check.

Checking existence first prevents unnecessary type and range checks on empty inputs. Additionally, verifying the data type before the range check avoids potential runtime errors for incompatible data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three validation techniques?

A

Type:
Used to confirm the data type of a given input

Range:
Used to ensure that a given input falls within specific allowable limits or values

Existence:
Verifies if an input contains data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly