![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-store/Model/Validation/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Store\Model\Validation; use Laminas\Validator\Regex; use Magento\Framework\Validator\AbstractValidator; use Magento\Framework\Validator\RegexFactory; /** * Validator for store code. */ class StoreCodeValidator extends AbstractValidator { /** * @var RegexFactory */ private $regexValidatorFactory; /** * @param RegexFactory $regexValidatorFactory */ public function __construct(RegexFactory $regexValidatorFactory) { $this->regexValidatorFactory = $regexValidatorFactory; } /** * @inheritDoc */ public function isValid($value) { $validator = $this->regexValidatorFactory->create(['pattern' => '/^[a-z]+[a-z0-9_]*$/i']); $validator->setMessage( __( 'The store code may contain only letters (a-z), numbers (0-9) or underscore (_),' . ' and the first character must be a letter.' ), Regex::NOT_MATCH ); $result = $validator->isValid($value); $this->_messages = $validator->getMessages(); return $result; } }