diff --git a/lab2/student.rb b/lab2/student.rb index 99d3793..e351eb7 100644 --- a/lab2/student.rb +++ b/lab2/student.rb @@ -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