type TNever = { /** * This property exists to stop TNever also including other types. * At time of writing, it seems to affect all that we use: `T[]`, `boolean`, `string` and `number`. */ neverType: string; }; /** An object used to facilitate activity input validation. */ export declare namespace validation { const never: TNever; /** * Coerces an array out of a value. * @param inputName The name of the input being checked. * @param value The value of the input. */ function array(inputName: string, value: T | T[] | undefined | null): T[] | undefined; /** * Coerces an array out of a value. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to use if `value` is `undefined` or `null`. When this is `validation.never` the function will throw an `ActivityInputError` instead. */ function array(inputName: string, value: T | T[] | undefined | null, defaultValue: undefined): T[] | undefined; /** * Coerces an array out of a value. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to use if `value` is `undefined` or `null`. When this is `validation.never` the function will throw an `ActivityInputError` instead. */ function array(inputName: string, value: T | T[] | undefined | null, defaultValue: T | T[] | TNever): T[]; function isBoolean(value: boolean | TNever): value is boolean; /** * Checks if the given value is a boolean. If not a default value is returned instead. * When `defaultValue` is `validation.never`, an error is thrown instead. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to use if `value` is `undefined` or `null`. When this is `validation.never` the function will throw an `ActivityInputError` instead. * @returns `value` if it is a boolean, `defaultValue` if it is a boolean. Otherwise an ActivityInputError is thrown. */ function boolean(inputName: string, value: any): boolean | undefined; /** * Checks if the given value is a boolean. If not a default value is returned instead. * When `defaultValue` is `validation.never`, an error is thrown instead. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to use if `value` is `undefined` or `null`. When this is `validation.never` the function will throw an `ActivityInputError` instead. * @returns `value` if it is a boolean, `defaultValue` if it is a boolean. Otherwise an ActivityInputError is thrown. */ function boolean(inputName: string, value: any, defaultValue: undefined): boolean | undefined; /** * Checks if the given value is a boolean. If not a default value is returned instead. * When `defaultValue` is `validation.never`, an error is thrown instead. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to use if `value` is `undefined` or `null`. When this is `validation.never` the function will throw an `ActivityInputError` instead. * @returns `value` if it is a boolean, `defaultValue` if it is a boolean. Otherwise an ActivityInputError is thrown. */ function boolean(inputName: string, value: any, defaultValue: boolean | TNever): boolean; /** * Checks if the given value is defined and throws an error if not. * @param inputName The name of the input being checked. * @param value The value of the input. * @returns The supplied value, if it is defined. * @throws An `ActivityInputError` if `value` is `undefined` or `null`. */ function exists(inputName: string, value: T | undefined): T; /** * Checks if the given value is defined and throws an error if not. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The default value to use when `value` is not defined. If `validation.never`, an error is thrown instead. * @returns The supplied value, if it is defined. Otherwise, `defaultValue` if it is not `validation.never`. * @throws An `ActivityInputError` if `value` is `undefined` or `null` and `defaultValue` is `validation.never`. */ function exists(inputName: string, value: T | undefined, defaultValue: T | TNever): T; function id(inputName: string, value: any): string | number | undefined; function id(inputName: string, value: any, defaultValue: undefined): string | number | undefined; function id(inputName: string, value: any, defaultValue: string | number | TNever): string | number; /** * Checks if the given value is a number or a type that can be converted into one. * If so, the numeric value is returned. * If not, `undefined` is returned. * @param inputName The name of the input being checked. * @param value The value of the input. */ function number(inputName: string, value: number): number; /** * Checks if the given value is a number or a type that can be converted into one. * If so, the numeric value is returned. * If not, `undefined` is returned. * @param inputName The name of the input being checked. * @param value The value of the input. */ function number(inputName: string, value: number | undefined): number | undefined; /** * Checks if the given value is a number or a type that can be converted into one. * If so, the numeric value is returned. * If not, `undefined` is returned. * @param inputName The name of the input being checked. * @param value The value of the input. */ function number(inputName: string, value: any): number | undefined; /** * Checks if the given value is a number or a type that can be converted into one. * If so, the numeric value is returned. * If not, `undefined` is returned. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue A value to return if `value` could not be converted to a number. */ function number(inputName: string, value: any, defaultValue: undefined): number | undefined; /** * Checks if the given value is a number or a type that can be converted into one. * If so, the numeric value is returned. * If not, `undefined` is returned. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue A value to return if `value` could not be converted to a number. If `validation.never`, an `ActivityInputError` is thrown instead. */ function number(inputName: string, value: any, defaultValue: number | TNever): number; /** * Checks if the given value is a string. * @param inputName The name of the input being checked. * @param value The value of the input. */ function string(inputName: string, value: string): string; /** * Checks if the given value is a string. * If so, the value is returned. If not, undefined is returned. * @param inputName The name of the input being checked. * @param value The value of the input. */ function string(inputName: string, value: any): string | undefined; /** * Checks if the given value is a string. * If so, the value is returned. If not, the default value is returned. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to return if `value` is not a string. */ function string(inputName: string, value: any, defaultValue: undefined): string | undefined; /** * Checks if the given value is a string. * If so, the value is returned. If not, the default value is returned * unless the default value is `validation.never`, in which case an `ActivityInputError` is thrown. * @param inputName The name of the input being checked. * @param value The value of the input. * @param defaultValue The value to return if `value` is not a string. */ function string(inputName: string, value: any, defaultValue: string | TNever): string; /** * Checks if an input object contains a url or an esri layer with a url. * @param inputs The inputs to an activity. * @returns The supplied layer, or a new FeatureLayer using the supplied url. */ function layer(inputs: { layer?: __esri.Layer | __esri.SubtypeSublayer; url?: string; }): __esri.Layer | __esri.SubtypeSublayer; /** Checks if an input object contains a url or an esri layer with a url. */ function urlOrLayer(inputs: { layer?: __esri.Layer | __esri.SubtypeSublayer; url?: string; }): string; } export {};