aboutsummaryrefslogtreecommitdiff
path: root/src/constants/regex.ts
diff options
context:
space:
mode:
authorLeon Jiang <35908040+leonyjiang@users.noreply.github.com>2020-07-08 09:56:17 -0700
committerGitHub <noreply@github.com>2020-07-08 12:56:17 -0400
commite32241734c8cc258812ac12c7727aaa7f947eed5 (patch)
tree8ef1ab3a5203496641be721a9567173b87c4f551 /src/constants/regex.ts
parentff358c8927086a69f6732b6e7e1abb85a9e3cc84 (diff)
[TMA-60] Registration Page UI & Field Validation (#13)
* remove unused image * refactor LoginInput component to be more generic * configure bare registration screen * create index files for exports * add yarn typing script * refactor and re-style LoginInput component * re-style login screen according to designs * make LoginInput name more generic, give TaggInput dirty & width props * add disabled feature to login screen submit button, finalized styles * add arrow images and create ArrowButton component * create RegistrationWizard component and move files around * added disabled & enabled buttons to ArrowButton component * create dummy terms and conditions text * create common CenteredView component for re-use * create custom RadioCheckbox for registration screen * create TermsConditions & OverlayView components * update index.ts export files * build registration page UI with basic validation * yarn lint/type & add platform-specific styling * add yarn type item to PR checklist * add react-native-animatable dependency to project * add regex variables to constants file * Add width prop for more flexible styling * Add types and disable auto-capitalization * Update email validation regex * Create linear-gradient background component * Update password regex and add inline docs * Refactor code to be more readable * Add warning prop and animation to TaggInput * Add wrapper View for vertical margins * Make JSX more readable & add TaggInput components * Integrate refactored code into registration page * Merge in login screen changes * Lint and fix file syntax * Fix function docs * Add ViewProps to CenterView props * Add KeyboardAvoidingView to Background component * Add blurOnSubmit for inputs, restore deleted handleLogin code * Create Verification screen and add it to routes * Add routing to Verification page upon success * Add API request upon registration submit * Trigger warning shaking animation on submit * Make disabled arrow touchable, tap triggers submit
Diffstat (limited to 'src/constants/regex.ts')
-rw-r--r--src/constants/regex.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/constants/regex.ts b/src/constants/regex.ts
new file mode 100644
index 00000000..350cb855
--- /dev/null
+++ b/src/constants/regex.ts
@@ -0,0 +1,21 @@
+/**
+ * The email regex has complex constraints compliant with RFC 5322 standards. More details can be found [here](https://emailregex.com/).
+ */
+export const emailRegex: RegExp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+
+/**
+ * The password regex has the following constraints
+ * - min. 8 chars, max. 120 chars ({8,120})
+ * - at least one numeric digit ([0-9])
+ * - at least one lowercase letter ([a-z])
+ * - at least one uppercase letter ([A-Z])
+ * - at least one special character ([^a-zA-z0-9])
+ */
+export const passwordRegex: RegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,120}$/;
+
+/**
+ * The username regex has the following constraints
+ * - min. 6 chars, max. 30 chars ({6,30})
+ * - match only alphanumerics, underscores, and periods
+ */
+export const usernameRegex: RegExp = /^[a-zA-Z0-9_.]{6,30}$/;