import { Result } from '../base'; import { BaseConverter } from './baseConverter'; import { Converter, ConverterTraits } from './converter'; /** * Options for {@link Conversion.StringConverter | StringConverter} * matching method * @public */ export interface StringMatchOptions { /** * An optional message to be displayed if a non-matching string * is encountered. */ message?: string; } /** * The {@link Conversion.StringConverter | StringConverter} class extends * {@link Conversion.BaseConverter | BaseConverter} to provide string-specific * helper methods. * @public */ export declare class StringConverter extends BaseConverter { /** * Construct a new {@link Conversion.StringConverter | StringConverter}. * @param defaultContext - Optional context used by the conversion. * @param traits - Optional traits to be applied to the conversion. * @param converter - Optional conversion function to be used for the conversion. */ constructor(defaultContext?: TC, traits?: ConverterTraits, converter?: (from: unknown, self: Converter, context?: TC) => Result); /** * @internal */ protected static _convert(from: unknown): Result; /** * @internal */ protected static _wrap(wrapped: StringConverter, converter: (from: T) => Result, traits?: ConverterTraits): StringConverter; /** * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match * a supplied string. * @param match - The string to be matched * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion. * @returns {@link Success} with a matching string or {@link Failure} with an informative * error if the string does not match. * {@label WITH_STRING} */ matching(match: string, options?: Partial): StringConverter; /** * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match * one of a supplied array of strings. * @param match - The array of allowed strings. * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion. * @returns {@link Success} with a matching string or {@link Failure} with an informative * error if the string does not match. * {@label WITH_ARRAY} */ matching(match: string[], options?: Partial): StringConverter; /** * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match * one of a supplied `Set` of strings. * @param match - The `Set` of allowed strings. * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion. * @returns {@link Success} with a matching string or {@link Failure} with an informative * error if the string does not match. * {@label WITH_SET} */ matching(match: Set, options?: Partial): StringConverter; /** * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match * a supplied regular expression. * @param match - The regular expression to be used as a constraint. * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion * @returns {@link Success} with a matching string or {@link Failure} with an informative * error if the string does not match. * {@label WITH_REGEXP} */ matching(match: RegExp, options?: Partial): StringConverter; } //# sourceMappingURL=stringConverter.d.ts.map