1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/models/child.rb

15 lines
366 B
Ruby
Raw Normal View History

2023-04-03 18:23:49 +02:00
# frozen_string_literal: true
# Child is a modal for a child of a user
class Child < ApplicationRecord
belongs_to :user
validates :first_name, presence: true
validates :last_name, presence: true
validate :validate_age
def validate_age
errors.add(:birthday, 'You should be over 18 years old.') if birthday.blank? && birthday < 18.years.ago
end
end