aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/logs.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/logs.ts')
-rw-r--r--server/helpers/custom-validators/logs.ts42
1 files changed, 0 insertions, 42 deletions
diff --git a/server/helpers/custom-validators/logs.ts b/server/helpers/custom-validators/logs.ts
deleted file mode 100644
index 215dbb0e1..000000000
--- a/server/helpers/custom-validators/logs.ts
+++ /dev/null
@@ -1,42 +0,0 @@
1import validator from 'validator'
2import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
3import { ClientLogLevel, ServerLogLevel } from '@shared/models'
4import { exists } from './misc'
5
6const serverLogLevels = new Set<ServerLogLevel>([ 'debug', 'info', 'warn', 'error' ])
7const clientLogLevels = new Set<ClientLogLevel>([ 'warn', 'error' ])
8
9function isValidLogLevel (value: any) {
10 return exists(value) && serverLogLevels.has(value)
11}
12
13function isValidClientLogMessage (value: any) {
14 return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_MESSAGE)
15}
16
17function isValidClientLogLevel (value: any) {
18 return exists(value) && clientLogLevels.has(value)
19}
20
21function isValidClientLogStackTrace (value: any) {
22 return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_STACK_TRACE)
23}
24
25function isValidClientLogMeta (value: any) {
26 return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_META)
27}
28
29function isValidClientLogUserAgent (value: any) {
30 return typeof value === 'string' && validator.isLength(value, CONSTRAINTS_FIELDS.LOGS.CLIENT_USER_AGENT)
31}
32
33// ---------------------------------------------------------------------------
34
35export {
36 isValidLogLevel,
37 isValidClientLogMessage,
38 isValidClientLogStackTrace,
39 isValidClientLogMeta,
40 isValidClientLogLevel,
41 isValidClientLogUserAgent
42}