UNPKG

node-switchbot

Version:

The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).

91 lines 4.05 kB
import type { ErrorObject, Rule } from './device.js'; import { EventEmitter } from 'node:events'; export declare class ParameterChecker extends EventEmitter { private _error; private readonly typeCheckers; /** * Emits a log event with the specified log level and message. * * @param level - The severity level of the log (e.g., 'info', 'warn', 'error'). * @param message - The log message to be emitted. */ private emitLog; /** * Gets the current error object. * * @returns {ErrorObject | null} - The current error object or null if no error. */ get error(): ErrorObject | null; /** * Checks if the value is specified (not undefined). * * @param {unknown} value - The value to check. * @returns {boolean} - True if the value is specified, false otherwise. */ isSpecified(value: unknown): boolean; /** * Checks if the specified object contains valid values based on the provided rules. * * @param {Record<string, unknown>} obj - Object including parameters you want to check. * @param {Record<string, Rule>} rules - Object including rules for the parameters. * @param {boolean} [required] - Flag whether the `obj` is required or not. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ check(obj: Record<string, unknown>, rules: Record<string, Rule>, required?: boolean): Promise<boolean>; /** * Checks if the value is a float. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isFloat(value: unknown, rule: Rule, name?: string): Promise<boolean>; /** * Checks if the value is an integer. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isInteger(value: unknown, rule: Rule, name?: string): Promise<boolean>; /** * Checks if the value is a boolean. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isBoolean(value: unknown, rule: Rule, name?: string): Promise<boolean>; /** * Checks if the value is an object. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isObject(value: unknown, rule: Rule, name?: string): Promise<boolean>; /** * Checks if the value is an array. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isArray(value: unknown, rule: Rule, name?: string): Promise<boolean>; /** * Checks if the value is a string. * * @param {unknown} value - The value to check. * @param {Rule} rule - The rule object containing validation criteria. * @param {string} [name] - The parameter name. * @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise. */ isString(value: unknown, rule: Rule, name?: string): Promise<boolean>; } export declare const parameterChecker: ParameterChecker; //# sourceMappingURL=parameter-checker.d.ts.map