mirror of
https://github.com/internetee/registry.git
synced 2025-07-13 14:35:05 +02:00
Introduce 'optional' validator to epp controllers
This commit is contained in:
parent
3a529135ea
commit
e6b36c409d
6 changed files with 96 additions and 16 deletions
|
@ -21,18 +21,9 @@ class Epp::KeyrelaysController < EppController
|
|||
'authInfo', 'authInfo > pw'
|
||||
)
|
||||
|
||||
optional 'expiry > relative', duration_iso8601: true
|
||||
optional 'expiry > absolute', date_time_iso8601: true
|
||||
exactly_one_of 'expiry > relative', 'expiry > absolute'
|
||||
|
||||
begin
|
||||
abs_datetime = params[:parsed_frame].css('absolute').text
|
||||
abs_datetime = DateTime.parse(abs_datetime) if abs_datetime.present?
|
||||
rescue => _e
|
||||
epp_errors << {
|
||||
code: '2005',
|
||||
msg: I18n.t('unknown_expiry_absolute_pattern'),
|
||||
value: { obj: 'expiry_absolute', val: abs_datetime }
|
||||
}
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue