@progress/kendo-angular-barcodes
Version:
Kendo UI Angular Barcodes
31 lines (30 loc) • 1.4 kB
TypeScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { ValidatorFn } from '@angular/forms';
import { geometry } from '@progress/kendo-drawing';
import { BarcodeType } from './chart-types';
/**
* Creates a validator for a specific Barcode type.
*
* Use this function to validate a Barcode value for a given `BarcodeType`.
*
* @param type Specifies the type of the Barcode.
* @param size Specifies the size of the barcode, excluding the text label, padding, and border. This parameter is optional.
* @returns Returns a validator function. The function returns an error map with the `barcode` property if validation fails. Otherwise, it returns `null` if valid.
*
* @example
* ```typescript
* const control = new FormControl('1234', createBarcodeValidator('EAN8'));
* console.log(control.errors);
* // {
* // barcode: {
* // message: 'The value of the "EAN13" encoding should be 12 symbols',
* // value: '1234',
* // type: 'EAN13'
* // }
* // }
* ```
*/
export declare const createBarcodeValidator: (type: BarcodeType, size?: geometry.Size) => ValidatorFn;