X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fabuses.ts;h=94719641abd7561ff6414c43c31c58d304d0e7ed;hb=795212f7acc690c88c86d0fab8772f6564d59cb8;hp=0ca06a2522df7124f1288219860b6e9a215f04ed;hpb=2291a412d25bd139398ca9e7a5131d0c1e4ffd7d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/abuses.ts b/server/helpers/custom-validators/abuses.ts index 0ca06a252..94719641a 100644 --- a/server/helpers/custom-validators/abuses.ts +++ b/server/helpers/custom-validators/abuses.ts @@ -1,9 +1,11 @@ import validator from 'validator' -import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, AbuseVideoIs, AbuseCreate } from '@shared/models' +import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' +import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@shared/models' import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' import { exists, isArray } from './misc' const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES +const ABUSE_MESSAGES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSE_MESSAGES function isAbuseReasonValid (value: string) { return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON) @@ -46,13 +48,18 @@ function isAbuseVideoIsValid (value: AbuseVideoIs) { ) } +function isAbuseMessageValid (value: string) { + return exists(value) && validator.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE) +} + // --------------------------------------------------------------------------- export { isAbuseReasonValid, isAbuseFilterValid, isAbusePredefinedReasonValid, - areAbusePredefinedReasonsValid as isAbusePredefinedReasonsValid, + isAbuseMessageValid, + areAbusePredefinedReasonsValid, isAbuseTimestampValid, isAbuseTimestampCoherent, isAbuseModerationCommentValid,