UNPKG

devexpress-reporting

Version:

DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.

44 lines (43 loc) 1.92 kB
/** * DevExpress HTML/JS Reporting (viewer\parameters\previewParameterValueValidator.js) * Version: 25.2.3 * Build date: Dec 15, 2025 * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * License: https://www.devexpress.com/Support/EULAs/universal.xml */ import { DotnetTypes } from '@devexpress/analytics-core/analytics-internal-native'; import { validateGuid, ValueEditorHelper } from '@devexpress/analytics-core/analytics-widgets-internal-native'; export class PreviewParameterValueValidator { _registerType(typeName, validator) { this._validatorMap[typeName] = validator; } constructor() { this._validatorMap = {}; this._numericTypes = [ DotnetTypes.SystemSByte, DotnetTypes.SystemDecimal, DotnetTypes.SystemInt64, DotnetTypes.SystemInt32, DotnetTypes.SystemInt16, DotnetTypes.SystemSingle, DotnetTypes.SystemDouble, DotnetTypes.SystemByte, DotnetTypes.SystemUInt16, DotnetTypes.SystemUInt32, DotnetTypes.SystemUInt64 ]; this._registerType(DotnetTypes.SystemString, (value) => typeof value === 'string'); this._registerType(DotnetTypes.SystemGuid, (value) => typeof value === 'string' && validateGuid(value)); this._registerType(DotnetTypes.SystemBoolean, (value) => typeof value === 'boolean'); this._registerType(DotnetTypes.SystemDateTime, (value) => { return !isNaN(new Date(value)); }); this._numericTypes.forEach((type) => this._registerType(type, (value) => typeof value === 'string' && ValueEditorHelper.isValid(type, undefined, value))); } validate(type, value) { return this._validatorMap[type] ? this._validatorMap[type](value) : true; } isNumericType(type) { return this._numericTypes.some(x => x === type); } }