logitar-validation
Version:
JavaScript validation library distributed by Logitar.
25 lines (24 loc) • 1 kB
TypeScript
/**
* Defines a message formatter.
*/
export interface MessageFormatter {
/**
* Formats a message with the given placeholders.
* @param message The message to format.
* @param placeholders The placeholders to replace in the message.
* @returns The formatted message.
*/
format(message: string, placeholders: Record<string, unknown>): string;
}
/**
* The default message formatter. This could use [mustache.js](https://github.com/janl/mustache.js), but we don't want to add a dependency for this. We simply replace occurrences of placeholder keys with their values, no other computation.
*/
export declare class DefaultMessageFormatter implements MessageFormatter {
/**
* Formats a message with the given placeholders.
* @param message The message to format.
* @param placeholders The placeholders to replace in the message.
* @returns The formatted message.
*/
format(message: string, placeholders: Record<string, unknown>): string;
}