-
Notifications
You must be signed in to change notification settings - Fork 45
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
Change validation rules in new participant form #377
Change validation rules in new participant form #377
Conversation
4e4f6cf
to
0e109d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled the brunch, tried to spoil it, but it seems to work well. From my point of view it solves all the problems mentioned in the task so I leave approve but I would love for sb (@w1stler, @stanislawK, @jacekkalbarczyk, @kristhina) more fluent with regex to check the two experssions in custom validators at the bottom - before we merge it.
import { | ||
slackNickValidator, | ||
gitHubUsernameValidator | ||
} from '../helpers/validation'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a neat trick to get around it - kudos!
frontend/src/helpers/validation.js
Outdated
|
||
export const slackNickValidator = helpers.regex( | ||
'slackNickValidator', | ||
/^[0-9A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ,.';\-_/()[\]{}]*$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate to be THAT guy but I would use: ąćęłńóśźżĄĆĘŁŃÓŚŹŻ
- just for the sake of my OCD (and readability).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
export const gitHubUsernameValidator = helpers.regex( | ||
'gitHubUsernameValidator', | ||
/^[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever You want match the character - literally with regex, it is safer to escape it and use "\-"
instead of "-"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stanislawK I have removed it as it causes lint failure: error: Unnecessary escape character: \- (no-useless-escape) at src/helpers/validation.js:10:26
and it seems fair, please check https://stackoverflow.com/questions/9589074/regex-should-hyphens-be-escaped for reference.
6afaddc
to
4fb4acd
Compare
* Change validation rules in new participant form * Change chars order in slackNickValidator
Story / Bug id:
#309
Description:
In new participant form:
Migrations:
N/A
New imports / dependencies:
N/A
What tests do I need to run to validate this change:
Manual check of front-end form validation as follows:
-
, with the constraint that username cannot start or end with-
,żźćńółęąś
, numbers and,.';-_/()[]{}
.