Open
Description
Detailed Description
When a student is signing up the form should check whether the provided username is valid.
Context
This change will reduce the number of usernames submitted which contain typo's. It will also verify that the username provided isn't an arbitrary string.
Possible Implementation
Validating of user input into forms is done within forms.py. Usage of RegEx is preferred over manual string parsing. If an invalid username is provided then the form should raise a ValidationError.
Example of valid usernames:
- mz4315
- abc13
- xy12315
- ab117
Example of invalid usernames:
- a1216
- abcf16
- a1b17
- ab1210
Activity
plietar commentedon Jun 22, 2017
Why is
ab1210
a bad username ?In general I don't see a point in checking usernames against a pattern. You'll need to check them against the real database eventually
martinzlocha commentedon Jun 22, 2017
I considered it bad because the student arrived to Imperial in 2010 therefore isnt a UG student probably.
The issue is that TeachDB is updated very late (late September) and I'm not sure when are other databases updated and if we have access to them. Given that we want to allocate the students ASAP it will be too late.
jamesprinc3 commentedon Jun 22, 2017
I don't think we should be inferring this much at a regex stage. Probably better to just check that there are some numbers and there are some letters, and they are below some sensible limit.
levex commentedon Jul 2, 2017
Possible regexp candidate:
^[A-z]{2,3}\d+$
martinzlocha commentedon Jul 5, 2017
Even better
^([A-z]{2}\d{3,5}|[A-z]{3}\d{2})$
if you want to be more specific.Edit: This won't actually work for everyone, use
^[A-z]{2,3}\d{2,5}$
instead.