mirror of
https://github.com/appium/appium.git
synced 2026-10-23 00:59:18 +08:00
18 lines
603 B
TypeScript
18 lines
603 B
TypeScript
export const validators = {
|
|
setUrl: (url: any) => {
|
|
// either an `xyz://`, `about:`, or `data:` scheme is allowed
|
|
if (!url || !url.match(/^([a-zA-Z0-9_+.-]+:\/\/)|(about:)|(data:)/)) {
|
|
throw new Error('Url or Uri must start with <scheme>://');
|
|
}
|
|
},
|
|
setNetworkConnection: (type: any) => {
|
|
if (!isNumber(type) || [0, 1, 2, 4, 6].indexOf(type) === -1) {
|
|
throw new Error('Network type must be one of 0, 1, 2, 4, 6');
|
|
}
|
|
},
|
|
};
|
|
|
|
function isNumber(o: any): o is number {
|
|
return typeof o === 'number' || !Number.isNaN(parseInt(o, 10)) || !Number.isNaN(parseFloat(o));
|
|
}
|