username sanitize
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
import { IsBoolean, Matches, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||||
import { isSet } from 'util/types';
|
import { isSet } from 'util/types';
|
||||||
|
|
||||||
export class CreateUsersDto {
|
export class CreateUsersDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
@Matches(/^[a-zA-Z0-9'-_]+$/)
|
||||||
readonly username: string;
|
readonly username: string;
|
||||||
readonly fortyTwoId: string;
|
readonly fortyTwoId: string;
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
success.username = ''
|
success.username = ''
|
||||||
errors.username = "Something went wrong";
|
errors.username = "Use [a-zA-Z0-9] and - _ .";
|
||||||
if (response.status === 409) {
|
if (response.status === 409) {
|
||||||
errors.username = `${set.username} is already in use, pick a different one.`;
|
errors.username = `${set.username} is already in use, pick a different one.`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user