Your IP : 216.73.216.220


Current Path : /var/www/html/vendor/magento/module-inventory/Model/Validators/
Upload File :
Current File : /var/www/html/vendor/magento/module-inventory/Model/Validators/NoWhitespaceInString.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Inventory\Model\Validators;

/**
 * Checks whether given value contains whitespace
 */
class NoWhitespaceInString
{
    /**
     * Checks whether given value contains whitespace
     *
     * @param string $fieldName
     * @param string $value
     * @return array
     */
    public function execute(string $fieldName, string $value): array
    {
        $errors = [];

        if (preg_match('/\s/', $value)) {
            $errors[] = __('"%field" can not contain whitespaces.', ['field' => $fieldName]);
        }

        return $errors;
    }
}