mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 20:19:34 +02:00
Story#111864739 - epp validation
This commit is contained in:
parent
14b246d692
commit
71aae06dd1
2 changed files with 22 additions and 0 deletions
|
@ -1,4 +1,7 @@
|
||||||
class LegalDocument < ActiveRecord::Base
|
class LegalDocument < ActiveRecord::Base
|
||||||
|
include EppErrors
|
||||||
|
MIN_BODY_SIZE = (1.37 * 8.kilobytes).ceil
|
||||||
|
|
||||||
if ENV['legal_document_types'].present?
|
if ENV['legal_document_types'].present?
|
||||||
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
|
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
|
||||||
else
|
else
|
||||||
|
@ -9,9 +12,24 @@ class LegalDocument < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :documentable, polymorphic: true
|
belongs_to :documentable, polymorphic: true
|
||||||
|
|
||||||
|
|
||||||
|
validate :val_body_length, if: ->(file){ file.path.blank? && !Rails.env.staging?}
|
||||||
|
|
||||||
before_create :add_creator
|
before_create :add_creator
|
||||||
before_save :save_to_filesystem
|
before_save :save_to_filesystem
|
||||||
|
|
||||||
|
def epp_code_map
|
||||||
|
{
|
||||||
|
'2306' => [
|
||||||
|
[:body, :length]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def val_body_length
|
||||||
|
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_to_filesystem
|
def save_to_filesystem
|
||||||
|
|
|
@ -205,6 +205,10 @@ en:
|
||||||
blank: 'Algorithm is missing'
|
blank: 'Algorithm is missing'
|
||||||
auth_info_pw:
|
auth_info_pw:
|
||||||
blank: 'Password is missing'
|
blank: 'Password is missing'
|
||||||
|
legal_document:
|
||||||
|
attributes:
|
||||||
|
body:
|
||||||
|
length: 'Parameter value policy error: legalDocument size should be more than 8kB'
|
||||||
|
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue