Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A table of part-time jobs has a field HoursPerWeek. It must be a whole number from to , including both ends.
hours > 1 AND hours < 40. Which values from part (b) does it get wrong?Validation is an automatic check that data is sensible before it is stored: a range check, a length check, a type check, a presence check, a format check or a check digit. A field can need several checks. Validation cannot prove that a sensible value is the true one.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. Count. The accepted values are . That is values.
Step 2. Test values. The ends and should be accepted. The values and , just outside, should be rejected.
Step 3. The wrong check. hours > 1 is false for , and hours < 40 is false for . So the check rejects and , which should be accepted. It handles and correctly.
Watch out. A range check that includes its ends needs >= and <=.
Answer: (a) values. (b) Accept and ; reject and . (c) It wrongly rejects and .
Log in to join the discussion.
Loading…