-
Notifications
You must be signed in to change notification settings - Fork 25
fix: char set validators #154
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
Conversation
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.
Reviewed 18 of 20 files at r1, all commit messages.
Reviewable status: 18 of 20 files reviewed, 3 unresolved discussions
codeforlife/user/serializers/klass.py
line 25 at r1 (raw file):
# TODO: add to model validators in new schema. name = serializers.CharField( validators=[AlphaCharSetValidator(spaces=True)],
Update to AlphaNumeric char set, allow spaces, dashes and underscores.
codeforlife/user/serializers/school.py
line 20 at r1 (raw file):
# TODO: add to model validators in new schema. name = serializers.CharField( validators=[AlphaCharSetValidator(spaces=True)],
Update to AlphaNumeric char set, allow spaces, full stops and apostrophes.
A lot schools are called after someone and might be called "St. John's" etc.
Also, if the school name already exists, teachers will instinctively try to add a 2 at the end.
codeforlife/validators/char_set.py
line 49 at r1 (raw file):
def __init__(self, spaces: bool = False, special_chars: str = ""): super().__init__( "a-zA-Z",
Does this allow for languages that do not use the roman alphabet?
Since we have users all around the world, we'd need these validators to allow for the use of other alphabets.
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.
Reviewed 18 of 18 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @SKairinos)
codeforlife/user/serializers/klass.py
line 25 at r1 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Update to AlphaNumeric char set, allow spaces, dashes and underscores.
Use UnicodeAlphanumericCharSetValidator and allow spaces, dashes and underscores please.
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @SKairinos)
codeforlife/user/serializers/user.py
line 37 at r2 (raw file):
max_length=150, read_only=True, )
For these, please also use UnicodeAlphaNumericCharSetValidator, and allow for spaces, dashes and apostrophes.
Mainly because there are a good amount of names (especially in the countries where cfl is used a lot) where -
and '
are common in names, as well and multiple names so spaces are needed.
I'm not 100% convinced about the need for numbers so we could stick to the Alpha char set, the only argument I can think of is that teachers can sometimes test the creation of students by entering "Student 1" etc.
Code quote:
# TODO: add to model validators in new schema.
first_name = serializers.CharField(
validators=[UnicodeAlphaCharSetValidator()],
max_length=150,
read_only=True,
)
# TODO: add to model validators in new schema.
last_name = serializers.CharField(
validators=[UnicodeAlphaCharSetValidator()],
max_length=150,
read_only=True,
)
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @faucomte97)
codeforlife/user/serializers/klass.py
line 25 at r1 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Use UnicodeAlphanumericCharSetValidator and allow spaces, dashes and underscores please.
Done.
codeforlife/user/serializers/school.py
line 20 at r1 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Update to AlphaNumeric char set, allow spaces, full stops and apostrophes.
A lot schools are called after someone and might be called "St. John's" etc.
Also, if the school name already exists, teachers will instinctively try to add a 2 at the end.
Done.
codeforlife/user/serializers/user.py
line 37 at r2 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
For these, please also use UnicodeAlphaNumericCharSetValidator, and allow for spaces, dashes and apostrophes.
Mainly because there are a good amount of names (especially in the countries where cfl is used a lot) where
-
and'
are common in names, as well and multiple names so spaces are needed.I'm not 100% convinced about the need for numbers so we could stick to the Alpha char set, the only argument I can think of is that teachers can sometimes test the creation of students by entering "Student 1" etc.
Done.
codeforlife/validators/char_set.py
line 49 at r1 (raw file):
Previously, faucomte97 (Florian Aucomte) wrote…
Does this allow for languages that do not use the roman alphabet?
Since we have users all around the world, we'd need these validators to allow for the use of other alphabets.
Yes, for example, in this PR I tested against Greek
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.
Reviewed 12 of 12 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @SKairinos)
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This change is