Skip to content

Commit 90b1c76

Browse files
committed
17754-Fixed validation while creating new product attributes in admin
1 parent 05a7954 commit 90b1c76

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ public function execute()
167167
$attributeCode = $attributeCode ?: $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
168168
if (strlen($attributeCode) > 0) {
169169
$validatorAttrCode = new \Zend_Validate_Regex(
170-
['pattern' => '/^[a-z\x{600}-\x{6FF}][a-z\x{600}-\x{6FF}_0-9]{0,30}$/u']
170+
['pattern' => '/^[a-zA-Z\x{600}-\x{6FF}][a-zA-Z\x{600}-\x{6FF}_0-9]{0,30}$/u']
171171
);
172172
if (!$validatorAttrCode->isValid($attributeCode)) {
173173
$this->messageManager->addErrorMessage(
174174
__(
175-
'Attribute code "%1" is invalid. Please use only letters (a-z), ' .
175+
'Attribute code "%1" is invalid. Please use only letters (a-z or A-Z), ' .
176176
'numbers (0-9) or underscore(_) in this field, first character should be a letter.',
177177
$attributeCode
178178
)

lib/web/mage/validation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,9 @@
980980
],
981981
'validate-code': [
982982
function (v) {
983-
return $.mage.isEmptyNoTrim(v) || /^[a-z]+[a-z0-9_]+$/.test(v);
983+
return $.mage.isEmptyNoTrim(v) || /^[a-zA-Z]+[a-zA-Z0-9_]+$/.test(v);
984984
},
985-
$.mage.__('Please use only letters (a-z), numbers (0-9) or underscore (_) in this field, and the first character should be a letter.') //eslint-disable-line max-len
985+
$.mage.__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in this field, and the first character should be a letter.') //eslint-disable-line max-len
986986
],
987987
'validate-alphanum': [
988988
function (v) {

0 commit comments

Comments
 (0)