-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
32 lines (25 loc) · 854 Bytes
/
index.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
import { Validator } from 'jsonschema';
import { multihash } from 'is-ipfs';
import { Buffer } from 'safe-buffer';
import { isValidAddress, isValidChecksumAddress } from 'ethereumjs-util';
// ethereum address validation
Validator.prototype.customFormats['address'] = function (input) {
if (input) {
return isValidAddress(input);
}
return true;
};
// checksummed ethereum address validation
Validator.prototype.customFormats['checkSummedAddress'] = function (input) {
return isValidChecksumAddress(input);
};
// ipfs multihash validation
Validator.prototype.customFormats['multihash'] = function (input) {
return multihash(input);
};
// Buffer type validation
Validator.prototype.customFormats['buffer'] = function (input) {
return Buffer.isBuffer(input);
};
// will add more over the time
export default Validator;