From e364e31e25bd1d4b8d801c845a96d6be708f0a18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 09:27:16 +0100 Subject: Implement signup approval in server --- .../helpers/custom-validators/user-registration.ts | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 server/helpers/custom-validators/user-registration.ts (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/user-registration.ts b/server/helpers/custom-validators/user-registration.ts new file mode 100644 index 000000000..9da0bb08a --- /dev/null +++ b/server/helpers/custom-validators/user-registration.ts @@ -0,0 +1,25 @@ +import validator from 'validator' +import { CONSTRAINTS_FIELDS, USER_REGISTRATION_STATES } from '../../initializers/constants' +import { exists } from './misc' + +const USER_REGISTRATIONS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USER_REGISTRATIONS + +function isRegistrationStateValid (value: string) { + return exists(value) && USER_REGISTRATION_STATES[value] !== undefined +} + +function isRegistrationModerationResponseValid (value: string) { + return exists(value) && validator.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.MODERATOR_MESSAGE) +} + +function isRegistrationReasonValid (value: string) { + return exists(value) && validator.isLength(value, USER_REGISTRATIONS_CONSTRAINTS_FIELDS.REASON_MESSAGE) +} + +// --------------------------------------------------------------------------- + +export { + isRegistrationStateValid, + isRegistrationModerationResponseValid, + isRegistrationReasonValid +} -- cgit v1.2.3