Skip to content

Commit

Permalink
fix(regexp): env var for index
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Dec 18, 2024
1 parent c0ce631 commit ba2d9a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DOMAIN=localhost
ORIGIN=http://localhost:3000
DATABASE_URL=postgres://root:mysecretpassword@localhost:5432/local
SECRET=changemeplsbutwith32charsbecauseyes
PUBLIC_INDEX_REGEX="^\d{1,4}[a-zA-Z]?\/(?:\d{2}|\d{4})$"

POSTGRES_USER=root
POSTGRES_PASSWORD=mysecretpassword
Expand Down
12 changes: 8 additions & 4 deletions src/lib/utils/regexp.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { env } from '$env/dynamic/public';

export const nameRegExp = /^[a-zA-ZčČćĆdžDŽđĐšŠžŽ]+(?:(?:\s|-)[a-zA-ZčČćĆdžDŽđĐšŠžŽ]+)?$/;
export const nameRegExpMsg = 'String must be 1-2 word(s) seperated by space or dash (-)';
export const nameRegExpMsg = 'String must be 1 or 2 word seperated by space or dash (-)';

export const indexRegExp = /^\d{1,4}[a-zA-Z]?\/(?:\d{2}|\d{4})(?:[A-Z]{1,3})?$/;
export const indexRegExp = new RegExp(
env.PUBLIC_INDEX_REGEX ?? /^\d{1,4}[a-zA-Z]?\/(?:\d{2}|\d{4})$/
);
export const indexRegExpMsg = 'String must follow Student ID format';

export const uppercaseRegExp = /^[A-Z0-9_\-+/\\|]*$/;
export const uppercaseRegExpMsg =
'String can consist of uppercase letters, numbers, and symbols (_, -, +, /, \, |)';
'String can consist of uppercase letters, numbers, and symbols (_, -, +, /, \\, |)';

export const lowercaseRegExp = /^[a-z0-9_\-+/\\|]*$/;
export const lowercaseRegExpMsg =
'String can consist of lowercase letters, numbers, and symbols (_, -, +, /, \, |)';
'String can consist of lowercase letters, numbers, and symbols (_, -, +, /, \\, |)';

0 comments on commit ba2d9a1

Please sign in to comment.