-
Notifications
You must be signed in to change notification settings - Fork 433
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
Character-based filters don't honor international characters #407
Comments
This is a really good point, thanks for bringing it up. I've struggled with something similar when I wanted to allow emoji characters. I think this can probably be solved in user land. We expose a validator called Let me know if that works for you or not. |
It sounds as if it would work but I can't test that in a timely manner and get back here to report the results. If I do manage to get a project using formsy I will definitely try and let you know. |
I just gave it a quick test and it worked as expected! Didn't have to do anything special. For example: <InputGroup
name="emoji"
label="emoji"
type="text"
validations={{
matchRegexp: XRegExp('^\\pS$', 'A'), // https://github.com/slevithan/xregexp#unicode
}}
validationError="Please enter an emoji"
/> I'll leave this open for now and close it once I add a note to our documentation. |
Good to know it worked, thanks. |
When trying the Dynamic Form Fields example, I entered some Hebrew characters on a field with the 'isAlphanumeric' filter but it did not validate. English characters were fine, but as soon as I added a Hebrew character the validation failed. The regex on the filter only checks for English letters and thus the validation fails. I believe this also fails on other international charachters, Thai, Chinese, Arabic, etc...
This is a bit tricky as JavaScript regexs are not UTF-8 friendly. There is a library called XRegExp which handles UTF-8 regexs but you don't want to add a library on top of your own library because that's funny. However, maybe you can "borrow" some code for detecting the international characters. I'm not sure, never dug into it too much, and it sounds funny as well.
In case anyone needs some Hebrew characters to copy paste and test: בהצלחה לכולם ויום הולדת שמח.
The text was updated successfully, but these errors were encountered: