New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@type-ddd/email

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@type-ddd/email

Library that provides TypeScript type definitions for handling Email in Domain-Driven Design contexts. It facilitates the validation and manipulation of emails.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67
decreased by-64.74%
Maintainers
0
Weekly downloads
 
Created
Source

@type-ddd/email

The @type-ddd/email module provides a class Email for handling email addresses in TypeScript. It includes methods for validating email addresses, extracting parts of the email (such as nickname and domain), and creating instances of validated emails.

Installation

Install rich-domain and @type-ddd/email with your favorite package manager:


npm i rich-domain @type-ddd/email

#OR 

yarn add rich-domain @type-ddd/email

Usage


import { Email } from '@type-ddd/email';

// Check if is valid value 
const isValid = Email.isValid('sample@domain.com');
// true

// Initialize Email instance with a valid email address
const email = Email.init('example@example.com');

// OR

// Create Email instance from provided email address
const result = Email.create('example@example.com');

// Get parts of the email address
const nickname = email.nick();
const domain = email.domain();


Block some domains

If you want to block some specifics domains


import { Email } from '@type-ddd/email';

const list = ['hack.com'];

Reflect.set(Email, 'BLOCKED_DOMAINS', list);

const isValid = Email.isValid('user@hack.com');
// false

const isValid = Email.isValid('user@gmail.com');
// true

Allowed some domains

If you want to allow only some specifics domains


import { Email } from '@type-ddd/email';

const list = ['my-company.com'];

Reflect.set(Email, 'VALID_DOMAINS', list);

const isValid = Email.isValid('user@my-company.com');
// true

const isValid = Email.isValid('user@gmail.com');
// false

Keywords

FAQs

Package last updated on 18 Dec 2024

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