-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathguards.ts
20 lines (19 loc) · 935 Bytes
/
guards.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { IDeployConfig } from './IonicCordova';
export function isPluginConfig(o: object): o is IDeployConfig {
const obj = <IDeployConfig>o;
const allowedKeys = ['appId', 'channel', 'disabled', 'host', 'maxVersions', 'minBackgroundDuration', 'updateMethod'];
if (!obj) return false;
for (const key in obj) {
if (allowedKeys.indexOf(key) === -1) {
return false;
}
}
return obj &&
(obj.appId === undefined || typeof obj.appId === 'string') &&
(obj.channel === undefined || typeof obj.channel === 'string') &&
(obj.disabled === undefined || typeof obj.disabled === 'string') &&
(obj.updateMethod === undefined || typeof obj.updateMethod === 'string') &&
(obj.maxVersions === undefined || typeof obj.maxVersions === 'number') &&
(obj.minBackgroundDuration === undefined || typeof obj.minBackgroundDuration === 'number') &&
(obj.host === undefined || typeof obj.host === 'string');
}