Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mjml-validator

Package Overview
Dependencies
Maintainers
6
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mjml-validator

mjml-validator

  • 4.9.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
623K
decreased by-8.9%
Maintainers
6
Weekly downloads
 
Created
Source

Validating MJML

MJML provides a validation layer that helps you building your email. It can detect if you misplaced or mispelled a MJML component, or if you used any unauthorised attribute on a specific component. It supports 3 levels of validation:

  • skip: your document is rendered without going through validation
  • soft: your document is going through validation and is rendered, even if it has errors
  • strict: your document is going through validation and is not rendered if it has any error

By default, the level is set to soft.

In CLI

When using the mjml command line, you can add the option -c.validationLevel or --config.validationLevel with the validation level you want.

Set the validation level to skip (so that the file is not validated) and render the file

mjml --config.validationLevel=skip template.mjml

Alternatively, you can just validate file without rendering it by add ing the --validate option

mjml --validate template.mjml

In Javascript

In Javascript, you can provide the level through the options parameters on mjml2html. Ex: mjml2html(inputMJML, { validationLevel: 'strict' })

strict will raise a MJMLValidationError exception. This object has 2 methods:

  • getErrors returns an array of objects with line, message, tagName as well as a formattedMessage which contains the line, message and tagName concatenated in a sentence.
  • getMessages returns an array of formattedMessage.

When using soft, no exception will be raised. You can get the errors in the object returned by mjml2html. It is the same object returned by getErrors on strict mode.

FAQs

Package last updated on 30 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc