/* * Copyright (c) 2010, 2026 BSI Business Systems Integration AG * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 */ import {FormFieldModel, ValueFieldClearable, ValueFieldFormatter, ValueFieldParser, ValueFieldValidator} from '../../index'; export interface ValueFieldModel extends FormFieldModel { /** * Configures the validators to be used when the value of the field needs to be validated (e.g. when the value changes). * * When the value is validated, every validator is called and has to agree. * If one validation fails, the value won't be accepted. * * If the validation needs to be asynchronous, the validator can return a promise. * The result of the promise is the validated value that will be passed to the remaining validators once the promise is resolved. * If the promise is rejected, the validation fails. * * By default, the list contains the default validator which is {@link ValueField._validateValue}. */ validators?: ValueFieldValidator[]; /** * Allows to have a single active validator, replaces all existing validators including the default one. * * @see ValueField.setValidator */ validator?: ValueFieldValidator; /** * The formatter is responsible to format the {@link value} so it can be used as {@link displayText}. * * The default formatter is passed as parameter and can be called during formatting, if needed. * * Default is {@link ValueField._formatValue}. * * @see ValueField.formatValue */ formatter?: ValueFieldFormatter; /** * The parser is responsible to parse the {@link displayText} and convert it into a {@link value}. * * Default is {@link _parseValue}. * * @see ValueField.parseValue */ parser?: ValueFieldParser; /** * Defines when the clear icon should be visible that allows the user to clear the value. * * Default is {@link ValueField.Clearable.FOCUSED} */ clearable?: ValueFieldClearable; /** * The main asset of the {@link ValueField}. * * The value is only accepted if it is valid according to the {@link validators}. * If the value is invalid, an {@link FormFieldModel.errorStatus} is shown. */ value?: TModelValue; /** * The textual representation of the {@link value}. * * The display text is computed automatically based on the {@link value} using the {@link formatter}. */ displayText?: string; /** * Configures the key of the message to be shown when the {@link value} is invalid. * * Default is `InvalidValueMessageX`. */ invalidValueMessageKey?: string; }