File tree 2 files changed +11
-13
lines changed
Customer/Model/Metadata/Form 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,6 @@ public function extractValue(\Magento\Framework\App\RequestInterface $request)
52
52
53
53
/**
54
54
* @inheritdoc
55
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
56
- * @SuppressWarnings(PHPMD.NPathComplexity)
57
55
*/
58
56
public function validateValue ($ value )
59
57
{
@@ -66,12 +64,12 @@ public function validateValue($value)
66
64
$ value = $ this ->_value ;
67
65
}
68
66
69
- if ($ attribute ->isRequired () && empty ($ value ) && $ value !== ' 0 ' ) {
70
- $ errors [] = __ ( ' "%1" is a required value. ' , $ label ) ;
67
+ if (! $ attribute ->isRequired () && empty ($ value )) {
68
+ return true ;
71
69
}
72
70
73
- if (! $ errors && ! $ attribute -> isRequired ( ) && empty ( $ value) ) {
74
- return true ;
71
+ if (empty ( $ value ) && $ value !== ' 0 ' ) {
72
+ $ errors [] = __ ( ' "%1" is a required value. ' , $ label ) ;
75
73
}
76
74
77
75
$ errors = $ this ->validateLength ($ value , $ attribute , $ errors );
@@ -80,6 +78,7 @@ public function validateValue($value)
80
78
if ($ result !== true ) {
81
79
$ errors = array_merge ($ errors , $ result );
82
80
}
81
+
83
82
if (count ($ errors ) == 0 ) {
84
83
return true ;
85
84
}
Original file line number Diff line number Diff line change @@ -55,8 +55,7 @@ public function extractValue(RequestInterface $request)
55
55
*
56
56
* @param array|string $value
57
57
* @return bool|array
58
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
59
- * @SuppressWarnings(PHPMD.NPathComplexity)
58
+ * @throws \Magento\Framework\Exception\LocalizedException
60
59
*/
61
60
public function validateValue ($ value )
62
61
{
@@ -68,13 +67,13 @@ public function validateValue($value)
68
67
$ value = $ this ->getEntity ()->getDataUsingMethod ($ attribute ->getAttributeCode ());
69
68
}
70
69
71
- if ($ attribute ->getIsRequired () && empty ($ value ) && $ value !== '0 ' ) {
72
- $ label = __ ($ attribute ->getStoreLabel ());
73
- $ errors [] = __ ('"%1" is a required value. ' , $ label );
70
+ if (!$ attribute ->getIsRequired () && empty ($ value )) {
71
+ return true ;
74
72
}
75
73
76
- if (!$ errors && !$ attribute ->getIsRequired () && empty ($ value )) {
77
- return true ;
74
+ if (empty ($ value ) && $ value !== '0 ' ) {
75
+ $ label = __ ($ attribute ->getStoreLabel ());
76
+ $ errors [] = __ ('"%1" is a required value. ' , $ label );
78
77
}
79
78
80
79
$ result = $ this ->validateLength ($ attribute , $ value );
You can’t perform that action at this time.
0 commit comments