Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable input length validation #2

Merged
merged 3 commits into from
Jan 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Model/CustomFields/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Bodak\CheckoutCustomForm\Helper\Config;
use Magento\Framework\Validator\AbstractValidator;
use Zend_Validate_Exception;
use Zend\Filter\Word\UnderscoreToCamelCase;


class Validator extends AbstractValidator
Expand All @@ -21,14 +22,21 @@ class Validator extends AbstractValidator
*/
private $config;

/**
* @var UnderscoreToCamelCase
*/
private $underscoreToCamelCase;

/**
* Validator constructor.
*
* @param Config $config
* @param UnderscoreToCamelCase $underscoreToCamelCase
*/
public function __construct(Config $config)
public function __construct(Config $config, UnderscoreToCamelCase $underscoreToCamelCase)
{
$this->config = $config;
$this->underscoreToCamelCase = $underscoreToCamelCase;
}

/**
Expand Down Expand Up @@ -96,6 +104,6 @@ private function lengthIsValid($attribute)
*/
private function convertSnakeToCamelCase($string)
amenk marked this conversation as resolved.
Show resolved Hide resolved
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string)))));
return $this->underscoreToCamelCase->filter($string);
}
}