Skip to content

validation.py

Nmoleo64 edited this page Mar 26, 2021 · 2 revisions

Description

validation.py contains the ValidateUsername function, which takes a username and a desired role and returns True if the username requirements have been met or False if they have not been met.

Conditions for a Valid Username

The conditions that must be met for a username to be valid are as follows:

  • The username must be no longer than 20 characters in length
  • The username cannot contain the characters <, >, (, or )
  • The username cannot be blank
  • The username must be unique and not already taken by another user in the session

Output

The ValidateUsername function will return a JSON object with two parameters: value and reason. Value will be a boolean True or False, specifying if the username was shown to be valid or not. Reason will contain the reason why the username was declared invalid, if applicable.

List of values for the reason field:

  • username_too_long - The username was greater than 20 characters in length
  • username_special_characters - The username contained disallowed special characters
  • username_blank - The username was blank
  • username_not_unique - The username was already taken

Table of Contents

Wiki Homepage

Python Code Documentation

JavaScript Code Documentation

Clone this wiki locally