Remove number and add int and float insted
This commit is contained in:
@ -4,13 +4,24 @@ export class VerificationError extends Error {
|
||||
public readonly field?: string,
|
||||
public readonly value?: any
|
||||
) {
|
||||
super("Parameter verification failed! " +(type ? "Expected " + type + "! " :"") + (field ? "At: " + field + "! " : ""));
|
||||
super(
|
||||
"Parameter verification failed! " +
|
||||
(type ? "Expected " + type + "! " : "") +
|
||||
(field ? "At: " + field + "! " : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function apply_number(data: any) {
|
||||
export function apply_int(data: any) {
|
||||
data = Math.floor(Number(data));
|
||||
if (Number.isNaN(data)) throw new VerificationError("int", undefined, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function apply_float(data: any) {
|
||||
data = Number(data);
|
||||
if(Number.isNaN(data)) throw new VerificationError("number", undefined, data);
|
||||
if (Number.isNaN(data))
|
||||
throw new VerificationError("float", undefined, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user