mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Use unknown for validators
This commit is contained in:
parent
c814187a25
commit
15168fb213
@ -1,5 +1,3 @@
|
|||||||
type ValidatorArg = object | string | undefined | null;
|
type ValidatorFunc = (obj: unknown) => (string | undefined);
|
||||||
|
|
||||||
type ValidatorFunc = (obj: ValidatorArg) => (string | undefined);
|
|
||||||
|
|
||||||
type ValidatorMap = Record<string, ValidatorFunc[]>;
|
type ValidatorMap = Record<string, ValidatorFunc[]>;
|
@ -1,19 +1,19 @@
|
|||||||
import noteTypeService = require('../services/note_types');
|
import noteTypeService = require('../services/note_types');
|
||||||
import dateUtils = require('../services/date_utils');
|
import dateUtils = require('../services/date_utils');
|
||||||
|
|
||||||
function mandatory(obj: ValidatorArg) {
|
function mandatory(obj: unknown) {
|
||||||
if (obj === undefined) {
|
if (obj === undefined) {
|
||||||
return `mandatory, but not set`;
|
return `mandatory, but not set`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function notNull(obj: ValidatorArg) {
|
function notNull(obj: unknown) {
|
||||||
if (obj === null) {
|
if (obj === null) {
|
||||||
return `cannot be null`;
|
return `cannot be null`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isString(obj: ValidatorArg) {
|
function isString(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ function isString(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLocalDateTime(obj: ValidatorArg) {
|
function isLocalDateTime(obj: unknown) {
|
||||||
if (typeof obj !== "string") {
|
if (typeof obj !== "string") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ function isLocalDateTime(obj: ValidatorArg) {
|
|||||||
return dateUtils.validateLocalDateTime(obj);
|
return dateUtils.validateLocalDateTime(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUtcDateTime(obj: ValidatorArg) {
|
function isUtcDateTime(obj: unknown) {
|
||||||
if (typeof obj !== "string") {
|
if (typeof obj !== "string") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ function isUtcDateTime(obj: ValidatorArg) {
|
|||||||
return dateUtils.validateUtcDateTime(obj);
|
return dateUtils.validateUtcDateTime(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBoolean(obj: ValidatorArg) {
|
function isBoolean(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ function isBoolean(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInteger(obj: ValidatorArg) {
|
function isInteger(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ function isInteger(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNoteId(obj: ValidatorArg) {
|
function isNoteId(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ function isNoteId(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNoteType(obj: ValidatorArg) {
|
function isNoteType(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ function isNoteType(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAttributeType(obj: ValidatorArg) {
|
function isAttributeType(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ function isAttributeType(obj: ValidatorArg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidEntityId(obj: ValidatorArg) {
|
function isValidEntityId(obj: unknown) {
|
||||||
if (obj === undefined || obj === null) {
|
if (obj === undefined || obj === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user