@cowwoc/requirements
Version:
A fluent API for enforcing design contracts with automatic message generation.
50 lines (49 loc) • 1.55 kB
text/typescript
import { Type, type StringMapper, StringMappers } from "./internal.mjs";
/**
* Returns the String representation of
*/
declare class MutableStringMappers {
private readonly typeToMapper;
/**
* Creates a new instance.
*
* @param typeToMapper - a mapping from the name of a type to the string representation of its values
*/
constructor(typeToMapper: Map<Type, StringMapper>);
/**
* Returns a mutable copy of the StringMappers.
*
* @param mappers - a `StringMappers` object
* @returns a mutable copy of the StringMappers
*/
static from(mappers: StringMappers): MutableStringMappers;
/**
* Returns an immutable copy of the mapper configuration.
*
* @returns an immutable copy of the mapper configuration
*/
toImmutable(): StringMappers;
/**
* Sets the function that maps a value of the given type to a string. This method is useful for customizing
* the formatting of validation failure messages.
*
* @param type - a type
* @param mapper - a function that returns the String representation of the type's instances
* @returns this
*/
put(type: Type, mapper: StringMapper): this;
/**
* Removes a mapper for a type.
*
* @param type - the type
* @returns this
*/
remove(type: Type): this;
/**
* Returns the string representation of this instance
*
* @returns the string representation of this instance
*/
toString(): string;
}
export { MutableStringMappers };