You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
853 lines
54 KiB
853 lines
54 KiB
9 months ago
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>
|
||
|
Module: Validations::SharedValidations
|
||
|
|
||
|
— Documentation by YARD 0.9.36
|
||
|
|
||
|
</title>
|
||
|
|
||
|
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
||
|
|
||
|
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
pathId = "Validations::SharedValidations";
|
||
|
relpath = '../';
|
||
|
</script>
|
||
|
|
||
|
|
||
|
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
||
|
|
||
|
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="nav_wrap">
|
||
|
<iframe id="nav" src="../class_list.html?1"></iframe>
|
||
|
<div id="resizer"></div>
|
||
|
</div>
|
||
|
|
||
|
<div id="main" tabindex="-1">
|
||
|
<div id="header">
|
||
|
<div id="menu">
|
||
|
|
||
|
<a href="../_index.html">Index (S)</a> »
|
||
|
<span class='title'>Validations</span>
|
||
|
»
|
||
|
<span class="title">SharedValidations</span>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div id="search">
|
||
|
|
||
|
<a class="full_list_link" id="class_list_link"
|
||
|
href="../class_list.html">
|
||
|
|
||
|
<svg width="24" height="24">
|
||
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
</svg>
|
||
|
</a>
|
||
|
|
||
|
</div>
|
||
|
<div class="clear"></div>
|
||
|
</div>
|
||
|
|
||
|
<div id="content"><h1>Module: Validations::SharedValidations
|
||
|
|
||
|
|
||
|
|
||
|
</h1>
|
||
|
<div class="box_info">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<dl>
|
||
|
<dt>Includes:</dt>
|
||
|
<dd>ActionView::Helpers::NumberHelper</dd>
|
||
|
</dl>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<dl>
|
||
|
<dt>Included in:</dt>
|
||
|
<dd><span class='object_link'><a href="DateValidations.html" title="Validations::DateValidations (module)">DateValidations</a></span>, <span class='object_link'><a href="FinancialValidations.html" title="Validations::FinancialValidations (module)">FinancialValidations</a></span>, <span class='object_link'><a href="HouseholdValidations.html" title="Validations::HouseholdValidations (module)">HouseholdValidations</a></span>, <span class='object_link'><a href="Sales/HouseholdValidations.html" title="Validations::Sales::HouseholdValidations (module)">Validations::Sales::HouseholdValidations</a></span>, <span class='object_link'><a href="Sales/SaleInformationValidations.html" title="Validations::Sales::SaleInformationValidations (module)">Validations::Sales::SaleInformationValidations</a></span>, <span class='object_link'><a href="Sales/SetupValidations.html" title="Validations::Sales::SetupValidations (module)">Validations::Sales::SetupValidations</a></span>, <span class='object_link'><a href="SetupValidations.html" title="Validations::SetupValidations (module)">SetupValidations</a></span>, <span class='object_link'><a href="TenancyValidations.html" title="Validations::TenancyValidations (module)">TenancyValidations</a></span></dd>
|
||
|
</dl>
|
||
|
|
||
|
|
||
|
|
||
|
<dl>
|
||
|
<dt>Defined in:</dt>
|
||
|
<dd>shared_validations.rb</dd>
|
||
|
</dl>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<h2>
|
||
|
Instance Method Summary
|
||
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
||
|
</h2>
|
||
|
|
||
|
<ul class="summary">
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#date_valid%3F-instance_method" title="#date_valid? (instance method)">#<strong>date_valid?</strong>(question, record) ⇒ Boolean </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#inactive_status-instance_method" title="#inactive_status (instance method)">#<strong>inactive_status</strong>(date, resource) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#location_during_startdate_validation-instance_method" title="#location_during_startdate_validation (instance method)">#<strong>location_during_startdate_validation</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#scheme_during_startdate_validation-instance_method" title="#scheme_during_startdate_validation (instance method)">#<strong>scheme_during_startdate_validation</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#shared_validate_partner_count-instance_method" title="#shared_validate_partner_count (instance method)">#<strong>shared_validate_partner_count</strong>(record, max_people) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#validate_numeric_min_max-instance_method" title="#validate_numeric_min_max (instance method)">#<strong>validate_numeric_min_max</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#validate_numeric_step-instance_method" title="#validate_numeric_step (instance method)">#<strong>validate_numeric_step</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#validate_other_field-instance_method" title="#validate_other_field (instance method)">#<strong>validate_other_field</strong>(record, value_other = nil, main_field = nil, other_field = nil, main_label = nil, other_label = nil) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#validate_owning_organisation_data_sharing_agremeent_signed-instance_method" title="#validate_owning_organisation_data_sharing_agremeent_signed (instance method)">#<strong>validate_owning_organisation_data_sharing_agremeent_signed</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
<li class="public ">
|
||
|
<span class="summary_signature">
|
||
|
|
||
|
<a href="#validate_property_postcode-instance_method" title="#validate_property_postcode (instance method)">#<strong>validate_property_postcode</strong>(record) ⇒ Object </a>
|
||
|
|
||
|
|
||
|
|
||
|
</span>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<span class="summary_desc"><div class='inline'></div></span>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div id="instance_method_details" class="method_details_list">
|
||
|
<h2>Instance Method Details</h2>
|
||
|
|
||
|
|
||
|
<div class="method_details first">
|
||
|
<h3 class="signature first" id="date_valid?-instance_method">
|
||
|
|
||
|
#<strong>date_valid?</strong>(question, record) ⇒ <tt>Boolean</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><div class="docstring">
|
||
|
<div class="discussion">
|
||
|
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="tags">
|
||
|
|
||
|
<p class="tag_title">Returns:</p>
|
||
|
<ul class="return">
|
||
|
|
||
|
<li>
|
||
|
|
||
|
|
||
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</div><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
116
|
||
|
117
|
||
|
118
|
||
|
119
|
||
|
120
|
||
|
121
|
||
|
122
|
||
|
123</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 116</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_date_valid?'>date_valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_question'>question</span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_question'>question</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeWithZone</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_question'>question</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_question'>question</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.date.invalid_date</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='kw'>false</span>
|
||
|
<span class='kw'>else</span>
|
||
|
<span class='kw'>true</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="inactive_status-instance_method">
|
||
|
|
||
|
#<strong>inactive_status</strong>(date, resource) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
87
|
||
|
88
|
||
|
89
|
||
|
90
|
||
|
91
|
||
|
92
|
||
|
93
|
||
|
94
|
||
|
95
|
||
|
96
|
||
|
97
|
||
|
98
|
||
|
99
|
||
|
100
|
||
|
101
|
||
|
102
|
||
|
103</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 87</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_inactive_status'>inactive_status</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_date'>date</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
|
||
|
|
||
|
<span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_status_at'>status_at</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>reactivating_soon</span><span class='words_sep'> </span><span class='tstring_content'>activating_soon</span><span class='words_sep'> </span><span class='tstring_content'>deactivated</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_status'>status</span><span class='rparen'>)</span>
|
||
|
|
||
|
<span class='id identifier rubyid_closest_reactivation'>closest_reactivation</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_last_deactivation_before'>last_deactivation_before</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_open_deactivation'>open_deactivation</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_open_deactivation'>open_deactivation</span>
|
||
|
|
||
|
<span class='id identifier rubyid_date'>date</span> <span class='op'>=</span> <span class='kw'>case</span> <span class='id identifier rubyid_status'>status</span>
|
||
|
<span class='kw'>when</span> <span class='symbol'>:reactivating_soon</span> <span class='kw'>then</span> <span class='id identifier rubyid_closest_reactivation'>closest_reactivation</span><span class='period'>.</span><span class='id identifier rubyid_reactivation_date'>reactivation_date</span>
|
||
|
<span class='kw'>when</span> <span class='symbol'>:activating_soon</span> <span class='kw'>then</span> <span class='id identifier rubyid_resource'>resource</span><span class='op'>&.</span><span class='id identifier rubyid_available_from'>available_from</span>
|
||
|
<span class='kw'>when</span> <span class='symbol'>:deactivated</span> <span class='kw'>then</span> <span class='id identifier rubyid_open_deactivation'>open_deactivation</span><span class='period'>.</span><span class='id identifier rubyid_deactivation_date'>deactivation_date</span>
|
||
|
<span class='kw'>end</span>
|
||
|
|
||
|
<span class='lbrace'>{</span> <span class='label'>scope:</span> <span class='id identifier rubyid_status'>status</span><span class='comma'>,</span> <span class='label'>date:</span> <span class='id identifier rubyid_date'>date</span><span class='op'>&.</span><span class='id identifier rubyid_to_formatted_s'>to_formatted_s</span><span class='lparen'>(</span><span class='symbol'>:govuk_date</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span> <span class='id identifier rubyid_closest_reactivation'>closest_reactivation</span><span class='op'>&.</span><span class='id identifier rubyid_deactivation_date'>deactivation_date</span><span class='op'>&.</span><span class='id identifier rubyid_to_formatted_s'>to_formatted_s</span><span class='lparen'>(</span><span class='symbol'>:govuk_date</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="location_during_startdate_validation-instance_method">
|
||
|
|
||
|
#<strong>location_during_startdate_validation</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
67
|
||
|
68
|
||
|
69
|
||
|
70
|
||
|
71
|
||
|
72
|
||
|
73
|
||
|
74
|
||
|
75
|
||
|
76</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 67</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_location_during_startdate_validation'>location_during_startdate_validation</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_location_inactive_status'>location_inactive_status</span> <span class='op'>=</span> <span class='id identifier rubyid_inactive_status'>inactive_status</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_startdate'>startdate</span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_location'>location</span><span class='rparen'>)</span>
|
||
|
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_location_inactive_status'>location_inactive_status</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
||
|
<span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_deactivation_date'>deactivation_date</span> <span class='op'>=</span> <span class='id identifier rubyid_location_inactive_status'>location_inactive_status</span><span class='period'>.</span><span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='symbol'>:date</span><span class='comma'>,</span> <span class='symbol'>:scope</span><span class='comma'>,</span> <span class='symbol'>:deactivation_date</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:startdate</span><span class='comma'>,</span> <span class='symbol'>:not_active</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.startdate.location.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scope'>scope</span><span class='embexpr_end'>}</span><span class='tstring_content'>.startdate</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>postcode:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_location'>location</span><span class='period'>.</span><span class='id identifier rubyid_postcode'>postcode</span><span class='comma'>,</span> <span class='label'>date:</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:location_id</span><span class='comma'>,</span> <span class='symbol'>:not_active</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.startdate.location.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scope'>scope</span><span class='embexpr_end'>}</span><span class='tstring_content'>.location_id</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>postcode:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_location'>location</span><span class='period'>.</span><span class='id identifier rubyid_postcode'>postcode</span><span class='comma'>,</span> <span class='label'>date:</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:scheme_id</span><span class='comma'>,</span> <span class='symbol'>:not_active</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.startdate.location.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scope'>scope</span><span class='embexpr_end'>}</span><span class='tstring_content'>.location_id</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>postcode:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_location'>location</span><span class='period'>.</span><span class='id identifier rubyid_postcode'>postcode</span><span class='comma'>,</span> <span class='label'>date:</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="scheme_during_startdate_validation-instance_method">
|
||
|
|
||
|
#<strong>scheme_during_startdate_validation</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
78
|
||
|
79
|
||
|
80
|
||
|
81
|
||
|
82
|
||
|
83
|
||
|
84
|
||
|
85</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 78</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_scheme_during_startdate_validation'>scheme_during_startdate_validation</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_scheme_inactive_status'>scheme_inactive_status</span> <span class='op'>=</span> <span class='id identifier rubyid_inactive_status'>inactive_status</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_startdate'>startdate</span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_scheme'>scheme</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_scheme_inactive_status'>scheme_inactive_status</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
||
|
<span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_deactivation_date'>deactivation_date</span> <span class='op'>=</span> <span class='id identifier rubyid_scheme_inactive_status'>scheme_inactive_status</span><span class='period'>.</span><span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='symbol'>:date</span><span class='comma'>,</span> <span class='symbol'>:scope</span><span class='comma'>,</span> <span class='symbol'>:deactivation_date</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:startdate</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.startdate.scheme.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scope'>scope</span><span class='embexpr_end'>}</span><span class='tstring_content'>.startdate</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_scheme'>scheme</span><span class='period'>.</span><span class='id identifier rubyid_service_name'>service_name</span><span class='comma'>,</span> <span class='label'>date:</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:scheme_id</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.startdate.scheme.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_scope'>scope</span><span class='embexpr_end'>}</span><span class='tstring_content'>.scheme_id</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_scheme'>scheme</span><span class='period'>.</span><span class='id identifier rubyid_service_name'>service_name</span><span class='comma'>,</span> <span class='label'>date:</span><span class='comma'>,</span> <span class='label'>deactivation_date:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="shared_validate_partner_count-instance_method">
|
||
|
|
||
|
#<strong>shared_validate_partner_count</strong>(record, max_people) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
105
|
||
|
106
|
||
|
107
|
||
|
108
|
||
|
109
|
||
|
110
|
||
|
111
|
||
|
112
|
||
|
113
|
||
|
114</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 105</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_shared_validate_partner_count'>shared_validate_partner_count</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_max_people'>max_people</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_start_year_after_2024?'>start_year_after_2024?</span>
|
||
|
|
||
|
<span class='id identifier rubyid_partner_numbers'>partner_numbers</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='int'>2</span><span class='op'>..</span><span class='id identifier rubyid_max_people'>max_people</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_person_is_partner?'>person_is_partner?</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>relat</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_partner_numbers'>partner_numbers</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>></span> <span class='int'>1</span>
|
||
|
<span class='id identifier rubyid_partner_numbers'>partner_numbers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>relat</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.household.relat.one_partner</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="validate_numeric_min_max-instance_method">
|
||
|
|
||
|
#<strong>validate_numeric_min_max</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
19
|
||
|
20
|
||
|
21
|
||
|
22
|
||
|
23
|
||
|
24
|
||
|
25
|
||
|
26
|
||
|
27
|
||
|
28
|
||
|
29
|
||
|
30
|
||
|
31
|
||
|
32
|
||
|
33
|
||
|
34
|
||
|
35
|
||
|
36</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 19</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_numeric_min_max'>validate_numeric_min_max</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_numeric_questions'>numeric_questions</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_question'>question</span><span class='op'>|</span>
|
||
|
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> <span class='op'>||</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
|
||
|
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='period'>.</span><span class='id identifier rubyid_routed_to?'>routed_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
||
|
|
||
|
<span class='kw'>begin</span>
|
||
|
<span class='id identifier rubyid_answer'>answer</span> <span class='op'>=</span> <span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>_before_type_cast</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
|
||
|
<span class='id identifier rubyid_add_range_error'>add_range_error</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_question'>question</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
|
||
|
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_answer'>answer</span>
|
||
|
|
||
|
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> <span class='op'>&&</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> <span class='op'>></span> <span class='id identifier rubyid_answer'>answer</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='op'>&&</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='op'><</span> <span class='id identifier rubyid_answer'>answer</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_add_range_error'>add_range_error</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_question'>question</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="validate_numeric_step-instance_method">
|
||
|
|
||
|
#<strong>validate_numeric_step</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
38
|
||
|
39
|
||
|
40
|
||
|
41
|
||
|
42
|
||
|
43
|
||
|
44
|
||
|
45
|
||
|
46
|
||
|
47
|
||
|
48
|
||
|
49
|
||
|
50
|
||
|
51
|
||
|
52
|
||
|
53
|
||
|
54
|
||
|
55
|
||
|
56
|
||
|
57</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 38</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_numeric_step'>validate_numeric_step</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_numeric_questions'>numeric_questions</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_question'>question</span><span class='op'>|</span>
|
||
|
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span>
|
||
|
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='period'>.</span><span class='id identifier rubyid_routed_to?'>routed_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
||
|
|
||
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>_before_type_cast</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_field'>field</span> <span class='op'>=</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_check_answer_label'>check_answer_label</span> <span class='op'>||</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
|
||
|
<span class='id identifier rubyid_incorrect_accuracy'>incorrect_accuracy</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_d'>to_d</span> <span class='op'>*</span> <span class='int'>100</span><span class='rparen'>)</span> <span class='op'>%</span> <span class='lparen'>(</span><span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span> <span class='op'>*</span> <span class='int'>100</span><span class='rparen'>)</span> <span class='op'>!=</span> <span class='int'>0</span>
|
||
|
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span> <span class='op'><</span> <span class='int'>1</span> <span class='op'>&&</span> <span class='id identifier rubyid_incorrect_accuracy'>incorrect_accuracy</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.numeric.nearest_hundredth</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>field:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_incorrect_accuracy'>incorrect_accuracy</span> <span class='op'>||</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_d'>to_d</span> <span class='op'>!=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='comment'># if the user enters a value in exponent notation (eg '4e1') the to_i method does not convert this to the correct value
|
||
|
</span> <span class='id identifier rubyid_field'>field</span> <span class='op'>=</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_check_answer_label'>check_answer_label</span> <span class='op'>||</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
|
||
|
<span class='kw'>case</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span>
|
||
|
<span class='kw'>when</span> <span class='int'>1</span> <span class='kw'>then</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='symbol'>:not_integer</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.numeric.whole_number</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>field:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>when</span> <span class='int'>10</span> <span class='kw'>then</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_question'>question</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.numeric.nearest_ten</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>field:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="validate_other_field-instance_method">
|
||
|
|
||
|
#<strong>validate_other_field</strong>(record, value_other = nil, main_field = nil, other_field = nil, main_label = nil, other_label = nil) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
4
|
||
|
5
|
||
|
6
|
||
|
7
|
||
|
8
|
||
|
9
|
||
|
10
|
||
|
11
|
||
|
12
|
||
|
13
|
||
|
14
|
||
|
15
|
||
|
16
|
||
|
17</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 4</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_other_field'>validate_other_field</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_value_other'>value_other</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_main_field'>main_field</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_other_field'>other_field</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_main_label'>main_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_other_label'>other_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_main_field'>main_field</span> <span class='op'>||</span> <span class='id identifier rubyid_other_field'>other_field</span>
|
||
|
|
||
|
<span class='id identifier rubyid_main_field_label'>main_field_label</span> <span class='op'>=</span> <span class='id identifier rubyid_main_label'>main_label</span> <span class='op'>||</span> <span class='id identifier rubyid_main_field'>main_field</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_humanize'>humanize</span><span class='lparen'>(</span><span class='label'>capitalize:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_other_field_label'>other_field_label</span> <span class='op'>=</span> <span class='id identifier rubyid_other_label'>other_label</span> <span class='op'>||</span> <span class='id identifier rubyid_other_field'>other_field</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_humanize'>humanize</span><span class='lparen'>(</span><span class='label'>capitalize:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_main_field'>main_field</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_value_other'>value_other</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_other_field'>other_field</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_main_field'>main_field</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.other_field_missing</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>main_field_label:</span><span class='comma'>,</span> <span class='label'>other_field_label:</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_other_field'>other_field</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.other_field_missing</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>main_field_label:</span><span class='comma'>,</span> <span class='label'>other_field_label:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_main_field'>main_field</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_value_other'>value_other</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_other_field'>other_field</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_other_field'>other_field</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.other_field_not_required</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>main_field_label:</span><span class='comma'>,</span> <span class='label'>other_field_label:</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="validate_owning_organisation_data_sharing_agremeent_signed-instance_method">
|
||
|
|
||
|
#<strong>validate_owning_organisation_data_sharing_agremeent_signed</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
125
|
||
|
126
|
||
|
127
|
||
|
128
|
||
|
129
|
||
|
130
|
||
|
131</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 125</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_owning_organisation_data_sharing_agremeent_signed'>validate_owning_organisation_data_sharing_agremeent_signed</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_skip_dpo_validation'>skip_dpo_validation</span>
|
||
|
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_owning_organisation_id_changed?'>owning_organisation_id_changed?</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_owning_organisation'>owning_organisation</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_owning_organisation'>owning_organisation</span><span class='period'>.</span><span class='id identifier rubyid_data_protection_confirmed?'>data_protection_confirmed?</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:owning_organisation_id</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.owning_organisation.data_sharing_agreement_not_signed</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<div class="method_details ">
|
||
|
<h3 class="signature " id="validate_property_postcode-instance_method">
|
||
|
|
||
|
#<strong>validate_property_postcode</strong>(record) ⇒ <tt>Object</tt>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</h3><table class="source_code">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<pre class="lines">
|
||
|
|
||
|
|
||
|
59
|
||
|
60
|
||
|
61
|
||
|
62
|
||
|
63
|
||
|
64
|
||
|
65</pre>
|
||
|
</td>
|
||
|
<td>
|
||
|
<pre class="code"><span class="info file"># File 'shared_validations.rb', line 59</span>
|
||
|
|
||
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_property_postcode'>validate_property_postcode</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_postcode'>postcode</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_postcode_full'>postcode_full</span>
|
||
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_postcode_known?'>postcode_known?</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='id identifier rubyid_postcode'>postcode</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_postcode'>postcode</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='const'>POSTCODE_REGEXP</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_error_message'>error_message</span> <span class='op'>=</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.postcode</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:postcode_full</span><span class='comma'>,</span> <span class='symbol'>:wrong_format</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='id identifier rubyid_error_message'>error_message</span>
|
||
|
<span class='kw'>end</span>
|
||
|
<span class='kw'>end</span></pre>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div id="footer">
|
||
|
Generated on Thu Apr 18 11:36:48 2024 by
|
||
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
||
|
0.9.36 (ruby-3.1.4).
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|