- Require name for Doctor and the first and last names for
Patient to be non-empty:
To the Doctor model, add this validation:
validates :name, presence: true
To the Patient model, add these validations:
validates :first_name, presence: true
validates :last_name, presence: true
- Require the office number for Doctor to be between 1 and 799.
validates :office_num, numericality: {
greater_than_or_equal_to: 1,
less_than_or_equal_to: 799 }
- Require the phone number for Doctor to be in the form
???/???-????:
To the Doctor model, add this validation:
validates :phone_num, format: { with: { /\d{3}\/\d{3}-\d{4}/ },
message "phone number should be formatted as ???/???-????" }
- Require the gender for Patient to be either
"F" or
"M".
Add this validation to the Patient model:
validates :gender, inclusion: { in: %w( F M ) }