Skip to content

TypeScript/JavaScript Email validation compatible with PHP's filter_var($value, FILTER_VALIDATE_EMAIL)

License

Notifications You must be signed in to change notification settings

mpyw/FILTER_VALIDATE_EMAIL.js

Repository files navigation

FILTER_VALIDATE_EMAIL.js npm version Build Status Coverage Status

Email validation compatible with PHP's filter_var($value, FILTER_VALIDATE_EMAIL)

Installing

NPM

npm install filter-validate-email

CDN

<script src="https://unpkg.com/filter-validate-email@latest/dist/filter-validate-email.min.js"></script>

It is strongly recommended that you replace latest with a fixed version.

Usage

Validate Unicode Email (default)

PHP

<?php

$value = '...';
$result = (bool)filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE);

JavaScript

import validateEmail from 'filter-validate-email'

const value = '...'
const result = validateEmail(value)

Validate Ascii Email

PHP

<?php

$value = '...';
$result = (bool)filter_var($value, FILTER_VALIDATE_EMAIL);

JavaScript

import validateEmail from 'filter-validate-email'

const value = '...'
const result = validateEmail(value, false)

Appendix

About

TypeScript/JavaScript Email validation compatible with PHP's filter_var($value, FILTER_VALIDATE_EMAIL)

Topics

Resources

License

Stars

Watchers

Forks