Skip to content

Commit ecbde54

Browse files
committed
feat: Add custom email validation to Hotel model
1 parent e5af406 commit ecbde54

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/models/hotel.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ def do_something_after_destroy
103103
validates :vacancy, inclusion: { in: [true, false] }
104104
validates :public_likes, exclusion: { in: [nil] }
105105

106+
validate :custom_validation
107+
def custom_validation
108+
return unless email.include?('rhossilibunkhouse.com')
109+
110+
errors.add(:email, 'cannot be from rhossilibunkhouse.com')
111+
end
112+
106113
def set_timestamps
107114
current_time = Time.now
108115
self.created_at = current_time if new_record?

0 commit comments

Comments
 (0)