|
@@ -1,12 +1,8 @@
|
|
|
import { ErrorV3 } from '@growi/core/dist/models';
|
|
import { ErrorV3 } from '@growi/core/dist/models';
|
|
|
import { body, validationResult, type ValidationChain } from 'express-validator';
|
|
import { body, validationResult, type ValidationChain } from 'express-validator';
|
|
|
|
|
|
|
|
-import { DEFAULT_PASSOWRD_MINIMUM_NUMBER } from '~/consts/user';
|
|
|
|
|
-
|
|
|
|
|
// form rules
|
|
// form rules
|
|
|
-export const registerRules = (minPasswordLength?: number): ValidationChain[] => {
|
|
|
|
|
- const fixedMinPasswordLength = minPasswordLength ?? DEFAULT_PASSOWRD_MINIMUM_NUMBER;
|
|
|
|
|
-
|
|
|
|
|
|
|
+export const registerRules = (minPasswordLength: number): ValidationChain[] => {
|
|
|
return [
|
|
return [
|
|
|
body('registerForm.username')
|
|
body('registerForm.username')
|
|
|
.matches(/^[\da-zA-Z\-_.]+$/)
|
|
.matches(/^[\da-zA-Z\-_.]+$/)
|
|
@@ -23,8 +19,8 @@ export const registerRules = (minPasswordLength?: number): ValidationChain[] =>
|
|
|
body('registerForm.password')
|
|
body('registerForm.password')
|
|
|
.matches(/^[\x20-\x7F]*$/)
|
|
.matches(/^[\x20-\x7F]*$/)
|
|
|
.withMessage('message.Password has invalid character')
|
|
.withMessage('message.Password has invalid character')
|
|
|
- .isLength({ min: fixedMinPasswordLength })
|
|
|
|
|
- .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: fixedMinPasswordLength }))
|
|
|
|
|
|
|
+ .isLength({ min: minPasswordLength })
|
|
|
|
|
+ .withMessage(new ErrorV3('message.Password minimum character should be more than n characters', undefined, undefined, { number: minPasswordLength }))
|
|
|
.not()
|
|
.not()
|
|
|
.isEmpty()
|
|
.isEmpty()
|
|
|
.withMessage('message.Password field is required'),
|
|
.withMessage('message.Password field is required'),
|