- FormSubmission =
Dry::Validation.Schema do
configure do
config.messages_file = File.join(Base.root, './errors.yml')
def company_number_format?(value)
value ? value.match(/^([\d]*\d){8}$/) : true
end
end
required(:date_signed).filled(:date?)
required(:company_number).filled(:str?)
required(:company_name).filled(:str?)
required(:company_authentication_code).filled(:str?)
required(:package_reference).filled(:str?)
required(:submission_number).filled(:str?, size?: 6)
required(:company_number).filled(:company_number_format?)
end
- CompanyDataRequest =
Dry::Validation.Schema do
configure do
config.messages_file = File.join(Base.root, './errors.yml')
def company_number_format?(value)
value ? value.match(/^([\d]*\d){8}$/) : true
end
end
required(:company_number).filled(:str?)
required(:company_authentication_code).filled(:str?, size?: 6)
required(:made_up_date).filled(:date?)
required(:company_number).filled(:company_number_format?)
end
- GetSubmissionStatus =
Dry::Validation.Schema do
configure do
config.messages_file = File.join(Base.root, './errors.yml')
def company_number_format?(value)
value ? value.match(/^([\d]*\d){8}$/) : true
end
end
optional(:company_number).maybe(:str?)
optional(:submission_number).filled(:str?)
required(:presenter_id).filled(:str?)
optional(:company_number).filled(:company_number_format?)
rule(company_number_or_submission_number_presence: %i[company_number submission_number]) do |company_number, submission_number|
company_number.filled?.then(submission_number.none?) & submission_number.filled?.then(company_number.none?)
end
end
- ConfirmationStatement =
Dry::Validation.Schema do
configure do
config.messages_file = File.join(Base.root, './errors.yml')
def shareholders_names_presence?(shareholdings)
check = shareholdings.map do |holdings|
holdings[:shareholders].any? do |i|
((i[:name][:surname] && i[:name][:forename]) && !i[:name][:amalgamated_name]) ||
(!(i[:name][:surname] || i[:name][:forename]) && i[:name][:amalgamated_name])
end
end
check.all?
end
def other_foreign_country?(shareholdings)
check = shareholdings.map do |holdings|
check = holdings[:shareholders].any? do |i|
next true unless i[:address]
!(i[:address][:country] && i[:address][:other_foreign_country])
end
end
check.all?
end
end
optional(:trading_on_market).filled(:bool?)
optional(:dtr_5_applies).filled(:bool?)
optional(:psc_exempt_as_trading_on_regulated_market).filled(:bool?)
optional(:psc_exempt_as_shares_admitted_on_market).filled(:bool?)
optional(:psc_exempt_as_trading_on_uk_regulated_market).filled(:bool?)
required(:review_date).filled(:date?)
optional(:sic_codes).schema do
required(:sic_code).each(:str?)
end
required(:state_confirmation).filled(:bool?)
end
- ReturnofAllotmentShares =
Dry::Validation.Schema do
required(:start_period_shares_allotted).filled(:date?)
optional(:end_period_shares_allotted).filled(:date?)
required(:statement_of_capital).schema do
required(:capital).each do
schema do
required(:total_amount_unpaid).filled(:str?)
required(:total_number_of_issued_shares).filled(:str?)
required(:share_currency).filled(:str?)
required(:total_aggregate_nominal_value).filled(:str?)
required(:shares).each do
schema do
required(:share_class).filled(:str?)
required(:prescribed_particulars).filled(:str?)
required(:num_shares).filled(:str?)
required(:aggregate_nominal_value).filled(:str?)
end
end
end
end
end
required(:allotment).each do
schema do
required(:share_class).filled(:str?)
required(:num_shares).filled(:str?)
required(:amount_paid_due_per_share).filled(:str?)
required(:amount_unpaid_per_share).filled(:str?)
required(:share_currency).filled(:str?)
required(:share_value).filled(:str?)
optional(:consideration).filled(:str?)
end
end
end