Skip to content

Commit

Permalink
Make phone number validation regex of Reservation model simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
ZaikoXander committed Oct 24, 2024
1 parent d86d43e commit 67c7647
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/reservation.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Reservation < ApplicationRecord
validates :name, presence: true
validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP }
validates :phone_number, presence: true, format: { with: /\A\+?[0-9]{10,15}\z/, message: "must be a valid phone number" }
validates :phone_number, presence: true, format: { with: /\d{10,11}\z/, message: "must be a valid phone number" }
validates :number_of_guests, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 9, message: "must be between 1 and 9 (9+)" }
validates :date, presence: true
validates :time, presence: true, format: { with: /\A([01]\d|2[0-3]):([0-5]\d)\z/, message: "must be in the format HH:MM" }
Expand Down

0 comments on commit 67c7647

Please sign in to comment.