Skip to content

Commit

Permalink
chore: 🤦 I should implement tests as soon as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Feb 12, 2022
1 parent 121dd99 commit 8977d25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function isValidUri(...values: (string | undefined)[]): boolean {
export function isNotBlank(...values: (string | undefined | null)[]): boolean {
let isValid = true;
for (const value of values) {
if (!value) return false;

isValid = isValid && !(value === undefined || value === null || value === '' || value.trim().length === 0);
if (!isValid) return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v1/admin/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const usersAdminHandler = (app: FastifyInstance, opts: FastifyPluginOptions, don

if (!hasRequirementsMet)
return Meiling.V1.Error.sendMeilingError(rep, Meiling.V1.Error.ErrorType.INVALID_REQUEST, 'Invalid Username');
if (Utils.isValidName(data.name))
if (!Utils.isValidName(data.name))
return Meiling.V1.Error.sendMeilingError(rep, Meiling.V1.Error.ErrorType.INVALID_REQUEST, 'Invalid Name');

const name = data.name;
Expand Down

0 comments on commit 8977d25

Please sign in to comment.