feat: add validation methods for Git link and contact presence

- Added `validate` method to ensure each Student object has a Git link and at least one contact method (phone, telegram, or email).
- Implemented `git_present?` method to check the presence of a Git link.
- Implemented `contact_present?` method to check the presence of at least one contact method.
- Modified the constructor to call `validate` during object initialization.
pull/4/head
Artem-Darius Weber 4 months ago
parent fca36ccd9d
commit c1ca0ea845

@ -46,6 +46,21 @@ class Student
@git = args[:git]
raise ArgumentError, "Invalid git format: #{@git}" unless Student.valid_git?(@git)
validate
end
def git_present?
!@git.nil? && !@git.empty?
end
def contact_present?
!(@phone.nil? || @phone.empty?) || !(@telegram.nil? || @telegram.empty?) || !(@email.nil? || @email.empty?)
end
def validate
raise ArgumentError, "Git link is required" unless git_present?
raise ArgumentError, "At least one contact (phone, telegram, or email) is required" unless contact_present?
end
def to_s

Loading…
Cancel
Save