Validating Numbers

Learn how to validate number fields.

We'll cover the following

In this lesson, we will show how to validate a number field. Currently, we don’t have a number field in the Athlete class. We will add a field rank to store the current ranking the player. The value of rank can be between 1 and 100. Any value outside this range should result in a validation error. The datatype of the newly added field is Integer instead of the primitive type int as it will help in making the field required and handling type conversion errors.

Get hands-on with 1400+ tech skills courses.