mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Validate Dispute.starts_at is not in future
This commit is contained in:
parent
529a8a1bf6
commit
5e152b3b9d
3 changed files with 11 additions and 7 deletions
|
@ -4,10 +4,7 @@ class Dispute < ApplicationRecord
|
|||
before_validation :set_expiry_date
|
||||
validate :validate_domain_name_format
|
||||
validate :validate_domain_name_period_uniqueness
|
||||
|
||||
with_options on: :admin do
|
||||
validate :validate_start_date
|
||||
end
|
||||
validate :validate_start_date
|
||||
|
||||
before_save :set_expiry_date
|
||||
before_save :sync_reserved_password
|
||||
|
@ -112,7 +109,7 @@ class Dispute < ApplicationRecord
|
|||
def validate_start_date
|
||||
return if starts_at.nil?
|
||||
|
||||
errors.add(:starts_at, :past) if starts_at.past?
|
||||
errors.add(:starts_at, :future) if starts_at.future?
|
||||
end
|
||||
|
||||
def validate_domain_name_format
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
<div class="col-md-7">
|
||||
<%= f.text_field(:starts_at, class: 'form-control js-datepicker') %>
|
||||
<span class="help-block"><%= t '.in_future' %></span>
|
||||
<span class="help-block"><%= t '.past_or_today' %></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
en:
|
||||
activerecord:
|
||||
errors:
|
||||
models:
|
||||
dispute:
|
||||
attributes:
|
||||
starts_at:
|
||||
future: 'can not be greater than today'
|
||||
admin:
|
||||
disputes:
|
||||
index:
|
||||
|
@ -9,4 +16,4 @@ en:
|
|||
form:
|
||||
password_hint: Generated automatically if left blank
|
||||
optional: Not required by default
|
||||
in_future: Must be at least today / in future
|
||||
past_or_today: Can not be greater than today's date
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue