'f'
mh-two-thousand-and-two
2024-04-12 26f2711ef9461961fb953e2b497bd314ef95e345
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const SIZE_TYPES = ['original', 'compressed']
const SOURCE_TYPES = ['album', 'camera']
 
export const chooseImage = {
  count: {
    type: Number,
    required: false,
    default: 9,
    validator (count, params) {
      if (count <= 0) {
        params.count = 9
      }
    }
  },
  sizeType: {
    type: [Array, String],
    required: false,
    default: SIZE_TYPES,
    validator (sizeType, params) {
      sizeType = typeof sizeType === 'string' ? [sizeType] : sizeType
      sizeType = sizeType.filter(sizeType => SIZE_TYPES.includes(sizeType))
      params.sizeType = sizeType.length ? sizeType : SIZE_TYPES
    }
  },
  sourceType: {
    type: Array,
    required: false,
    default: SOURCE_TYPES,
    validator (sourceType, params) {
      sourceType = sourceType.filter(sourceType => SOURCE_TYPES.includes(sourceType))
      params.sourceType = sourceType.length ? sourceType : SOURCE_TYPES
    }
  },
  extension: {
    type: Array,
    default: ['*'],
    validator (extension, params) {
      if (extension.length === 0) { return 'param extension should not be empty.' }
    }
  }
}