UNPKG

juvo-rafa-library

Version:

A comprehensive Angular component library featuring real-world components and validators extracted from the Juvo Rafa backoffice application. Now with improved select components and bug fixes.

33 lines (32 loc) 1.02 kB
import { ValidatorFn } from '@angular/forms'; /** * Validator function for serial port names * * @description * Validates that the input value matches a valid serial port naming format. * Supports Windows (COM1-COM99999), Linux/Unix (ttyUSB0, ttyACM0, ttyS0), and macOS (cu.*) formats. * * @example * ```typescript * // Basic usage in FormControl * const serialControl = new FormControl('', [serialPortValidator()]); * * // Usage in reactive forms * this.deviceForm = this.fb.group({ * serialPort: ['', [Validators.required, serialPortValidator()]] * }); * * // Valid inputs: * // Windows: 'COM1', 'COM10', 'COM99999' * // Linux: 'ttyUSB0', 'ttyACM0', 'ttyS1' * // macOS: 'cu.usbserial-1410', 'cu.Bluetooth-Incoming-Port' * * // Invalid inputs: 'invalid-port', 'COM', 'tty', 'random-string' * ``` * * @returns ValidatorFn that returns null if valid, or validation error object if invalid * * @since 2.0.0 * @author Juvo Rafa Team */ export declare function serialPortValidator(): ValidatorFn;