/
isBase64.ts
62 lines (60 loc) · 1.58 KB
/
isBase64.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { isBase64 } from '@terascope/utils';
import { FieldType } from '@terascope/types';
import {
FieldValidateConfig, ProcessMode, FunctionDefinitionType,
FunctionDefinitionCategory, FunctionDefinitionExample
} from '../interfaces';
const examples: FunctionDefinitionExample<Record<string, unknown>>[] = [
{
args: {},
config: {
version: 1,
fields: {
testField: {
type: FieldType.String
}
}
},
field: 'testField',
input: 'ZnJpZW5kbHlOYW1lNw==',
output: 'ZnJpZW5kbHlOYW1lNw=='
},
{
args: {},
config: {
version: 1,
fields: {
testField: {
type: FieldType.String
}
}
},
field: 'testField',
input: 'manufacturerUrl7',
output: null
},
{
args: {},
config: {
version: 1,
fields: {
testField: {
type: FieldType.Number
}
}
},
field: 'testField',
input: 1234123,
output: null
}
];
export const isBase64Config: FieldValidateConfig = {
name: 'isBase64',
type: FunctionDefinitionType.FIELD_VALIDATION,
process_mode: ProcessMode.INDIVIDUAL_VALUES,
category: FunctionDefinitionCategory.STRING,
examples,
description: 'Returns the input if it is a valid base64 string, otherwise returns null.',
create() { return isBase64; },
accepts: [FieldType.String],
};