Parse the source syntax representation of an MF2 message into its corresponding data model representation. Throws on syntax errors, but does not check for data model errors. To check for data model errors, use validate:
source
import { MessageSyntaxError, parseMessage, validate } from 'messageformat';try { const msg = parseMessage('Hello {$world}'); validate(msg);} catch (error) { if (error instanceof MessageSyntaxError) { // MessageDataModelError extends MessageSyntaxError ... }} Copy
import { MessageSyntaxError, parseMessage, validate } from 'messageformat';try { const msg = parseMessage('Hello {$world}'); validate(msg);} catch (error) { if (error instanceof MessageSyntaxError) { // MessageDataModelError extends MessageSyntaxError ... }}
Parse the
source
syntax representation of an MF2 message into its corresponding data model representation. Throws on syntax errors, but does not check for data model errors. To check for data model errors, use validate: