You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

email-style-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-style-validator

A utility for validating css styles against email clients compatibility.

1.1.2
latest
Source
npmnpm
Version published
Weekly downloads
5
-61.54%
Maintainers
1
Weekly downloads
 
Created
Source

Email Style Validator

Email Style Validator is simply a higher-order function that you pass a config and it returns a function that ensures css styles used are compatible with the email clients you specify in the config. Full listing of all supported clients.

Example usage:

const config = {
	supportedClients: [
		"Outlook 2007–16",
		"Gmail",
		"Yahoo! Mail",
	],
}

const emailStyleValidator = require('email-style-validator')

const myEmailStyleValidator = emailStyleValidator(config)

You can now invoke your style validator and pass it a style object. The style object is simply a plain javascript object with keys that are css styles and the corresponding values. It will ensure all styles used are compatible with the email clients you selected. It will return an object with the following properties:

const style = {
	border: '1px solid #E0E0E0',
	padding: '15px',
	'flex-grow': '1',
	'flex-shrink': '1',
	'flex-basis': 'auto',
}

const {
	isValid,
	partiallySupported,
	notSupported,
} = myEmailStyleValidator({ style })
  • isValid: A boolean that will be false if any style is not supported. Will be true if all styles are supported or partially supported.
  • partiallySupported: An array of objects identifying partially supported styles.
    • style: A string naming the partially supported style.
    • info: A string describing the partial support.
    • client: A string naming the email client.
  • notSupported: An array of objects identifying styles that are not supported.
    • style: A string naming the unsupported style.
    • client: A string naming the email client.

support.json

Email Style Validator checks for support using a json document that is generated by scraping CampaignMonitor's Ultimate Guide to CSS: "A complete breakdown of the CSS support for the most popular mobile, web and desktop email clients on the planet."

Email Style Validator is framework agnostic and can be used in the browser or on the server.

FAQs

Package last updated on 07 Dec 2017

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