Skip to content
AFresnedo edited this page Sep 16, 2018 · 12 revisions
Table of Contents

User

User Model

Motivation

Allows users to have personal information and allows for controlled site usage.

Implementation

{
  email: string_email_format_validated_required
  name: string_name_required
  password: string_hashed_before_saving
  type: string_client_or_provider
  admin: boolean_must_be_hardcoded_into_database
}

Email Validation

Uses a broad regex to validate proper e-mail format. This implementation is more inclusive than exclusive.

/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

/ = Begin an expression
^ = The matched string must begin here, and only begin here
\w = any word (letters, digits, underscores)
+ = match previous expression at least once, unlimited number of times
[] = match any character inside the brackets, but only match one
\+\. = match a literal + or .
\w = another word
- = match a literal -
* = match the previous expression zero or infinite times
@ = match a literal @ symbol
() = make everything inside the parentheses a group (and make them referencable)
[] = another character set
\w- = match any word or a literal -
+ = another 1 to infinity quantifier
\. = match another literal .
* = another 0 to infinity quantifier
\w+ = match a word at least once
[\w-]*\. = match a word or a dash at least zero times, followed by a literal .
() = another group
[a-z]{2,4} = match lowercase letters at least 2 times but no more than 4 times
| = "or" (does not match pipe)
\d+ = match at least 1 digit
$ = the end of the string
/ = end an expression
i = test the string in a case insensitive manner

Clone this wiki locally