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

Ajout de Methodes #1

Closed
ghost opened this issue May 29, 2019 · 2 comments
Closed

Ajout de Methodes #1

ghost opened this issue May 29, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented May 29, 2019

Proposition d'ajout de méthodes qui m'ont été utile.

Pattern Matching

   public function patternMatch(string $key, string $pattern): self
    {
        if (!empty($value = $this->getValue($key))) {
            if (is_null($value) || !preg_match($pattern, $value)) {
                $this->addError($key, 'pattern match');
            }
        }
        return $this;
    }

Alpha numérique


    public function isAlphaNum(string ...$keys): self
    {
        foreach ($keys as $key)
        {
            if (!empty($value = $this->getValue($key))) {
                if (!ctype_alnum($value)) {
                    $this->addError($key, 'isAlphaNum');
                }
            }
        }
        return $this;
    }
@lefuturiste
Copy link
Owner

je vais le faire sauf si tu veux faire une PR avec les tests et tout

lefuturiste added a commit that referenced this issue May 29, 2019
warn: add ext-ctype dependency
@lefuturiste
Copy link
Owner

methods added!

just a little thing: the method isAlphaNum was renamed alphaNumerical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant