diff --git a/src/scripts/classes/query/handiwork-search-query.ts b/src/scripts/classes/query/handiwork-search-query.ts index 2bed0ae..13134bc 100644 --- a/src/scripts/classes/query/handiwork-search-query.ts +++ b/src/scripts/classes/query/handiwork-search-query.ts @@ -5,9 +5,9 @@ "use strict"; -import { AxiosResponse } from "axios"; // Public modules from npm -import validator from "class-validator"; +import { IsInt, Min, validateSync } from "class-validator"; +import { AxiosResponse } from "axios"; // Module from files import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; @@ -70,10 +70,10 @@ export default class HandiworkSearchQuery implements IQuery { * Results presentation order. */ public order: THandiworkOrder = "relevance"; - @validator.IsInt({ + @IsInt({ message: "$property expect an integer, received $value" }) - @validator.Min(HandiworkSearchQuery.MIN_PAGE, { + @Min(HandiworkSearchQuery.MIN_PAGE, { message: "The minimum $property value must be $constraint1, received $value" }) public page = 1; @@ -103,7 +103,7 @@ export default class HandiworkSearchQuery implements IQuery { } public validate(): boolean { - return validator.validateSync(this).length === 0; + return validateSync(this).length === 0; } public async execute(): Promise { @@ -112,7 +112,7 @@ export default class HandiworkSearchQuery implements IQuery { // Check if the query is valid if (!this.validate()) { - throw new Error(`Invalid query: ${validator.validateSync(this).join("\n")}`); + throw new Error(`Invalid query: ${validateSync(this).join("\n")}`); } // Convert the query @@ -144,7 +144,7 @@ export default class HandiworkSearchQuery implements IQuery { // Cast the basic query object and copy common values const query: LatestSearchQuery = new LatestSearchQuery(); Object.keys(this).forEach((key) => { - if (query.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(query, key)) { query[key] = this[key]; } }); @@ -165,7 +165,7 @@ export default class HandiworkSearchQuery implements IQuery { // Cast the basic query object and copy common values const query: ThreadSearchQuery = new ThreadSearchQuery(); Object.keys(this).forEach((key) => { - if (query.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(query, key)) { query[key] = this[key]; } });