Skip to content

Commit 8f0c225

Browse files
committed
adding validation to unit test, line before return statement, and remove unused jquery/ui from validation
1 parent 4974628 commit 8f0c225

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,16 @@ public function testGetHtmlExtraParamsWithoutRequiredOption()
521521
{
522522
$this->escaper->expects($this->any())
523523
->method('escapeHtml')
524-
->with('{"validate-date":{"dateFormat":"M\/d\/Y"}}')
525-
->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"}}'));
524+
->with('{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}')
525+
->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}'));
526526

527527
$this->attribute->expects($this->once())
528528
->method("isRequired")
529529
->willReturn(false);
530530

531531
$this->assertEquals(
532532
$this->_block->getHtmlExtraParams(),
533-
'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"}}"'
533+
'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}"'
534534
);
535535
}
536536

@@ -544,13 +544,13 @@ public function testGetHtmlExtraParamsWithRequiredOption()
544544
->willReturn(true);
545545
$this->escaper->expects($this->any())
546546
->method('escapeHtml')
547-
->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}')
548-
->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}'));
547+
->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}')
548+
->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}'));
549549

550550
$this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper));
551551

552552
$this->assertEquals(
553-
'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}"',
553+
'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}"',
554554
$this->_block->getHtmlExtraParams()
555555
);
556556
}

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@
260260
<argument name="data" xsi:type="array">
261261
<item name="config" xsi:type="array">
262262
<item name="source" xsi:type="string">customer</item>
263-
<item name="options" xsi:type="array">
264-
<item name="maxDate" xsi:type="string">-1d</item>
265-
</item>
266263
</item>
267264
</argument>
268265
<settings>
@@ -273,6 +270,15 @@
273270
<dataType>text</dataType>
274271
<visible>true</visible>
275272
</settings>
273+
<formElements>
274+
<date>
275+
<settings>
276+
<options>
277+
<option name="maxDate" xsi:type="string">-1d</option>
278+
</options>
279+
</settings>
280+
</date>
281+
</formElements>
276282
</field>
277283
<field name="taxvat" formElement="input">
278284
<argument name="data" xsi:type="array">

app/code/Magento/Customer/view/frontend/web/js/validation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require([
22
'jquery',
33
'moment',
4-
'jquery/ui',
54
'jquery/validate',
65
'mage/translate',
76
], function($, moment) {
@@ -12,6 +11,7 @@ require([
1211
if (value === '') {
1312
return true;
1413
}
14+
1515
return moment(value).isBefore(moment());
1616
},
1717
$.mage.__('The Date of Birth should not be greater than today.')

0 commit comments

Comments
 (0)