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

validate phrase #106

Closed
hachreak opened this issue Sep 12, 2014 · 2 comments
Closed

validate phrase #106

hachreak opened this issue Sep 12, 2014 · 2 comments

Comments

@hachreak
Copy link

Hi,
there is possibility to validate string with spaces, accents, etc like "hello it's my message... XD".
I thinks it's possible if you use is_string() php function.
It's possible to add this function? :)

thanks
Leo

@mryellow
Copy link

mryellow commented Nov 7, 2014

I'm always surprised that frameworks leave this rule out, seems like the most common rule needed. However each persons needs can differ depending on character sets and internationalisation.

Valitron\Validator::addRule('alphaNumSpace', function($field, $value, array $params) {
    return preg_match("/^[a-z\d\-_\s]+$/i", $value);
}, 'must contain only letters a-z and/or numbers 0-9 and/or spaces');

This may be a better regex depending on your needs.
http://stackoverflow.com/a/13283557/2438830

@willemwollebrants
Copy link
Collaborator

The regex rule is ideal for this

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

3 participants