-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): added user color feature
- Loading branch information
1 parent
f5c2f5c
commit c6a7b6e
Showing
7 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
IsHexColor, | ||
ValidationArguments, | ||
ValidatorConstraint, | ||
ValidatorConstraintInterface, | ||
} from "class-validator"; | ||
import { isColorTooDark } from '../../utils' | ||
import { Validate } from "class-validator"; | ||
import { ArgsType, Field } from "type-graphql"; | ||
|
||
@ValidatorConstraint({ name: "validateColor", async: false }) | ||
class ValidateColor implements ValidatorConstraintInterface { | ||
validate(text: string, args: ValidationArguments) { | ||
return !isColorTooDark(text); | ||
} | ||
|
||
defaultMessage(args: ValidationArguments) { | ||
return "Color value ($value) is too dark"; | ||
} | ||
} | ||
|
||
@ArgsType() | ||
export class setColorArgs { | ||
@Field({ nullable: false }) | ||
@IsHexColor() | ||
@Validate(ValidateColor) | ||
color: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters