aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/actor-images.ts
blob: 4fb0b7c703653124e6232f32abbdfb35159cb794 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                                                                
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { isFileValid } from './misc'

const imageMimeTypes = CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
  .map(v => v.replace('.', ''))
  .join('|')
const imageMimeTypesRegex = `image/(${imageMimeTypes})`
function isActorImageFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], fieldname: string) {
  return isFileValid(files, imageMimeTypesRegex, fieldname, CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max)
}

// ---------------------------------------------------------------------------

export {
  isActorImageFile
}