mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +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
|
before_validation :set_expiry_date
|
||||||
validate :validate_domain_name_format
|
validate :validate_domain_name_format
|
||||||
validate :validate_domain_name_period_uniqueness
|
validate :validate_domain_name_period_uniqueness
|
||||||
|
validate :validate_start_date
|
||||||
with_options on: :admin do
|
|
||||||
validate :validate_start_date
|
|
||||||
end
|
|
||||||
|
|
||||||
before_save :set_expiry_date
|
before_save :set_expiry_date
|
||||||
before_save :sync_reserved_password
|
before_save :sync_reserved_password
|
||||||
|
@ -112,7 +109,7 @@ class Dispute < ApplicationRecord
|
||||||
def validate_start_date
|
def validate_start_date
|
||||||
return if starts_at.nil?
|
return if starts_at.nil?
|
||||||
|
|
||||||
errors.add(:starts_at, :past) if starts_at.past?
|
errors.add(:starts_at, :future) if starts_at.future?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_domain_name_format
|
def validate_domain_name_format
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
<%= f.text_field(:starts_at, class: 'form-control js-datepicker') %>
|
<%= 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>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
en:
|
en:
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
dispute:
|
||||||
|
attributes:
|
||||||
|
starts_at:
|
||||||
|
future: 'can not be greater than today'
|
||||||
admin:
|
admin:
|
||||||
disputes:
|
disputes:
|
||||||
index:
|
index:
|
||||||
|
@ -9,4 +16,4 @@ en:
|
||||||
form:
|
form:
|
||||||
password_hint: Generated automatically if left blank
|
password_hint: Generated automatically if left blank
|
||||||
optional: Not required by default
|
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