Fix --no-prototype-builtins

pull/77/head
MillenniumEarl 2021-03-08 12:18:52 +01:00
parent f40354e79a
commit a4be89c5fc
1 changed files with 8 additions and 8 deletions

View File

@ -5,9 +5,9 @@
"use strict"; "use strict";
import { AxiosResponse } from "axios";
// Public modules from npm // Public modules from npm
import validator from "class-validator"; import { IsInt, Min, validateSync } from "class-validator";
import { AxiosResponse } from "axios";
// Module from files // Module from files
import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js";
@ -70,10 +70,10 @@ export default class HandiworkSearchQuery implements IQuery {
* Results presentation order. * Results presentation order.
*/ */
public order: THandiworkOrder = "relevance"; public order: THandiworkOrder = "relevance";
@validator.IsInt({ @IsInt({
message: "$property expect an integer, received $value" 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" message: "The minimum $property value must be $constraint1, received $value"
}) })
public page = 1; public page = 1;
@ -103,7 +103,7 @@ export default class HandiworkSearchQuery implements IQuery {
} }
public validate(): boolean { public validate(): boolean {
return validator.validateSync(this).length === 0; return validateSync(this).length === 0;
} }
public async execute(): Promise<TExecuteResult> { public async execute(): Promise<TExecuteResult> {
@ -112,7 +112,7 @@ export default class HandiworkSearchQuery implements IQuery {
// Check if the query is valid // Check if the query is valid
if (!this.validate()) { 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 // Convert the query
@ -144,7 +144,7 @@ export default class HandiworkSearchQuery implements IQuery {
// Cast the basic query object and copy common values // Cast the basic query object and copy common values
const query: LatestSearchQuery = new LatestSearchQuery(); const query: LatestSearchQuery = new LatestSearchQuery();
Object.keys(this).forEach((key) => { Object.keys(this).forEach((key) => {
if (query.hasOwnProperty(key)) { if (Object.prototype.hasOwnProperty.call(query, key)) {
query[key] = this[key]; query[key] = this[key];
} }
}); });
@ -165,7 +165,7 @@ export default class HandiworkSearchQuery implements IQuery {
// Cast the basic query object and copy common values // Cast the basic query object and copy common values
const query: ThreadSearchQuery = new ThreadSearchQuery(); const query: ThreadSearchQuery = new ThreadSearchQuery();
Object.keys(this).forEach((key) => { Object.keys(this).forEach((key) => {
if (query.hasOwnProperty(key)) { if (Object.prototype.hasOwnProperty.call(query, key)) {
query[key] = this[key]; query[key] = this[key];
} }
}); });