mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Add types for 'commons-validator-js' (#36241)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
2d339041fd
commit
9fc90d53a9
@@ -0,0 +1,25 @@
|
||||
import commonsValidatorJs = require('commons-validator-js');
|
||||
|
||||
const emailValidator = new commonsValidatorJs.EmailValidator();
|
||||
const domainValidator = new commonsValidatorJs.DomainValidator();
|
||||
|
||||
// $ExpectType boolean
|
||||
emailValidator.isValid('a@a.com');
|
||||
|
||||
// $ExpectType string | null
|
||||
domainValidator.extractTld('a@a.com');
|
||||
|
||||
// $ExpectType boolean
|
||||
domainValidator.isValid('a@a.com');
|
||||
|
||||
// $ExpectType boolean
|
||||
domainValidator.isValidCountryCodeTld('de');
|
||||
|
||||
// $ExpectType boolean
|
||||
domainValidator.isValidGenericTld('com');
|
||||
|
||||
// $ExpectType boolean
|
||||
domainValidator.isValidInfrastructureTld('com');
|
||||
|
||||
// $ExpectType boolean
|
||||
domainValidator.isValidTld('com');
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for commons-validator-js 1.0
|
||||
// Project: https://github.com/wix/commons-validator-js
|
||||
// Definitions by: Robert Mruczek <https://github.com/rtmruczek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class EmailValidator {
|
||||
/**
|
||||
* @param allowLocal Should local addresses be considered valid? default = false
|
||||
* @param allowTld Should TLDs be allowed? default = false
|
||||
*/
|
||||
constructor({allowLocal, allowTld}?: {allowLocal: boolean, allowTld: boolean});
|
||||
isValid: (email: string) => boolean;
|
||||
}
|
||||
|
||||
export class DomainValidator {
|
||||
/**
|
||||
* @param allowLocal Should local addresses be considered valid? default = false
|
||||
*/
|
||||
constructor({allowLocal}?: {allowLocal: boolean});
|
||||
isValidCountryCodeTld: (ccTld: string) => boolean;
|
||||
isValidGenericTld: (gTld: string) => boolean;
|
||||
isValidInfrastructureTld: (iTld: string) => boolean;
|
||||
isValidTld: (tld: string) => boolean;
|
||||
extractTld: (domain: string) => string | null;
|
||||
isValid: (domain: string) => boolean;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"commons-validator-js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user