Options
All
  • Public
  • Public/Protected
  • All
Menu

segno - deno validation library

segno (Segnosaurus). Validation library for Deno 🦕. Enforcing a high security standard.

Example

import { segno, isIP } from 'https://deno.land/x/segno/mod.ts';

console.log(segno.isEmail('foo@example.org')); // true
console.log(isIP('127.0.0.1')); // true

Documentation

A documentation is currently still WIP. But please check our website https://segno.js.org for now.

License

License

Index

Type aliases

Algorithm

Algorithm: "md5" | "md4" | "sha1" | "sha256" | "sha384" | "sha512" | "ripemd128" | "ripemd160" | "tiger128" | "tiger160" | "tiger192" | "crc32" | "crc32b"

Base64Options

Base64Options: { urlSafe?: undefined | false | true }

Type declaration

  • Optional urlSafe?: undefined | false | true

ByteLengthOptions

ByteLengthOptions: { max?: undefined | number; min?: undefined | number }

Type declaration

  • Optional max?: undefined | number
    default

    undefined

  • Optional min?: undefined | number
    default

    0

CountryCode

CountryCode: "AM" | "AR" | "AT" | "AU" | "BE" | "BG" | "CA" | "CH" | "CN" | "CY" | "CZ" | "DE" | "DK" | "DZ" | "EE" | "ES" | "FI" | "FR" | "GB" | "GR" | "HR" | "HU" | "IE" | "IN" | "IS" | "IT" | "JP" | "KR" | "LT" | "LU" | "LV" | "MT" | "NL" | "PO" | "PT" | "RO" | "SE" | "SL" | "SK" | "TR" | "UA" | "US"

CurrencyOptions

CurrencyOptions: { allowDecimal?: undefined | false | true; allowNegativeSignPlaceholder?: undefined | false | true; allowNegatives?: undefined | false | true; allowSpaceAfterDigits?: undefined | false | true; allowSpaceAfterSymbol?: undefined | false | true; decimalSeparator?: undefined | string; digitsAfterDecimal?: number[]; negativeSignAfterDigits?: undefined | false | true; negativeSignBeforeDigits?: undefined | false | true; parensForNegatives?: undefined | false | true; requireDecimal?: undefined | false | true; requireSymbol?: undefined | false | true; symbol?: undefined | string; symbolAfterDigits?: undefined | false | true; thousandsSeparator?: undefined | string }

Type declaration

  • Optional allowDecimal?: undefined | false | true
  • Optional allowNegativeSignPlaceholder?: undefined | false | true
  • Optional allowNegatives?: undefined | false | true
  • Optional allowSpaceAfterDigits?: undefined | false | true
  • Optional allowSpaceAfterSymbol?: undefined | false | true
  • Optional decimalSeparator?: undefined | string
  • Optional digitsAfterDecimal?: number[]
  • Optional negativeSignAfterDigits?: undefined | false | true
  • Optional negativeSignBeforeDigits?: undefined | false | true
  • Optional parensForNegatives?: undefined | false | true
  • Optional requireDecimal?: undefined | false | true
  • Optional requireSymbol?: undefined | false | true
  • Optional symbol?: undefined | string
  • Optional symbolAfterDigits?: undefined | false | true
  • Optional thousandsSeparator?: undefined | string

DecimalOptions

DecimalOptions: { decimalDigits?: undefined | string; forceDecimal?: undefined | false | true; locale?: undefined | string }

Type declaration

  • Optional decimalDigits?: undefined | string
  • Optional forceDecimal?: undefined | false | true
  • Optional locale?: undefined | string

EmailOptions

EmailOptions: { allowDisplayName?: undefined | false | true; allowIPDomain?: undefined | false | true; allowUTF8LocalPart?: undefined | false | true; domainSpecificValidation?: undefined | false | true; ignoreMaxLength?: undefined | false | true; requireDisplayName?: undefined | false | true; requireTLD?: undefined | false | true }

Type declaration

  • Optional allowDisplayName?: undefined | false | true

    If set to true, the validator will also match Display Name <email-address>.

    default

    false

  • Optional allowIPDomain?: undefined | false | true

    If set to true, the validator will allow IP addresses in the host part.

    default

    false

  • Optional allowUTF8LocalPart?: undefined | false | true

    If set to false, the validator will not allow any non-English UTF8 character in email address' local part.

    default

    true

  • Optional domainSpecificValidation?: undefined | false | true

    If set to true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.

    default

    false

  • Optional ignoreMaxLength?: undefined | false | true

    If set to true, the validator will not check for the standard max length of an email.

    default

    false

  • Optional requireDisplayName?: undefined | false | true

    If set to true, the validator will reject strings without the format Display Name <email-address>.

    default

    false

  • Optional requireTLD?: undefined | false | true

    If set to false, e-mail addresses without having TLD in their domain will also be matched.

    default

    true

EmptyOptions

EmptyOptions: { ignoreWhitespace?: undefined | false | true }

Type declaration

  • Optional ignoreWhitespace?: undefined | false | true

FQDNOptions

FQDNOptions: { allowTrailingDot?: undefined | false | true; allowUnderscores?: undefined | false | true; requireTLD?: undefined | false | true }

Type declaration

  • Optional allowTrailingDot?: undefined | false | true
    default

    false

  • Optional allowUnderscores?: undefined | false | true
    default

    false

  • Optional requireTLD?: undefined | false | true
    default

    true

FloatOptions

FloatOptions: { gt?: undefined | number; locale?: undefined | string; lt?: undefined | number; max?: undefined | number; min?: undefined | number }

Type declaration

  • Optional gt?: undefined | number
  • Optional locale?: undefined | string
  • Optional lt?: undefined | number
  • Optional max?: undefined | number
  • Optional min?: undefined | number

IMEIOptions

IMEIOptions: { allowHyphens?: undefined | false | true }

Type declaration

  • Optional allowHyphens?: undefined | false | true

ISO8601Options

ISO8601Options: { strict?: undefined | false | true }

Type declaration

  • Optional strict?: undefined | false | true

ISSNOptions

ISSNOptions: { caseSensitive?: undefined | false | true; requireHyphen?: undefined | false | true }

Type declaration

  • Optional caseSensitive?: undefined | false | true
  • Optional requireHyphen?: undefined | false | true

IdentityCardLocale

IdentityCardLocale: "ES" | "IN" | "NO" | "he-IL" | "ar-TN" | "zh-CN" | "zh-TW" | "any"

IntOptions

IntOptions: { allowLeadingZeroes?: undefined | false | true; gt?: undefined | number; lt?: undefined | number; max?: undefined | number; min?: undefined | number }

Type declaration

  • Optional allowLeadingZeroes?: undefined | false | true
  • Optional gt?: undefined | number
  • Optional lt?: undefined | number
  • Optional max?: undefined | number
  • Optional min?: undefined | number

JSONOptions

JSONOptions: { allowPrimitives?: undefined | false | true }

Type declaration

  • Optional allowPrimitives?: undefined | false | true

LatLongOptions

LatLongOptions: { checkDMS?: undefined | false | true }

Type declaration

  • Optional checkDMS?: undefined | false | true

LengthOptions

LengthOptions: { max?: undefined | number; min?: undefined | number }

Type declaration

  • Optional max?: undefined | number
  • Optional min?: undefined | number

MACAddressOptions

MACAddressOptions: { noColons?: undefined | false | true }

Type declaration

  • Optional noColons?: undefined | false | true

MobilePhoneOptions

MobilePhoneOptions: { strictMode?: undefined | false | true }

Type declaration

  • Optional strictMode?: undefined | false | true

NumericOptions

NumericOptions: { locale?: any; noSymbols?: undefined | false | true }

Type declaration

  • Optional locale?: any
  • Optional noSymbols?: undefined | false | true

PhoneLocale

PhoneLocale: "am-AM" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LY" | "ar-SA" | "ar-SY" | "ar-TN" | "bs-BA" | "be-BY" | "bg-BG" | "bn-BD" | "cs-CZ" | "da-DK" | "de-DE" | "de-AT" | "de-CH" | "el-GR" | "en-AU" | "en-GB" | "en-GG" | "en-GH" | "en-HK" | "en-MO" | "en-IE" | "en-IN" | "en-KE" | "en-MT" | "en-MU" | "en-NG" | "en-NZ" | "en-PK" | "en-RW" | "en-SG" | "en-SL" | "en-TZ" | "en-UG" | "en-US" | "en-ZA" | "en-ZM" | "en-ZW" | "es-CO" | "es-CL" | "es-CR" | "es-EC" | "es-ES" | "es-MX" | "es-PA" | "es-PY" | "es-UY" | "et-EE" | "fa-IR" | "fi-FI" | "fj-FJ" | "fo-FO" | "fr-FR" | "fr-GF" | "fr-GP" | "fr-MQ" | "fr-RE" | "he-IL" | "hu-HU" | "id-ID" | "it-IT" | "ja-JP" | "kk-KZ" | "kl-GL" | "ko-KR" | "lt-LT" | "ms-MY" | "nb-NO" | "ne-NP" | "nl-BE" | "nl-NL" | "nn-NO" | "pl-PL" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "sl-SI" | "sk-SK" | "sr-RS" | "sv-SE" | "th-TH" | "tr-TR" | "uk-UA" | "vi-VN" | "zh-CN" | "zh-TW" | "en-CA" | "fr-BE" | "zh-HK" | "zh-MO" | "any"

PostalCode

PostalCode: "AD" | "AT" | "AU" | "BE" | "BG" | "BR" | "CA" | "CH" | "CZ" | "DE" | "DK" | "DZ" | "EE" | "ES" | "FI" | "FR" | "GB" | "GR" | "HR" | "HU" | "ID" | "IE" | "IL" | "IN" | "IS" | "IT" | "JP" | "KE" | "LI" | "LT" | "LU" | "LV" | "MX" | "MT" | "NL" | "NO" | "NP" | "NZ" | "PL" | "PR" | "PT" | "RO" | "RU" | "SA" | "SE" | "SI" | "SK" | "TN" | "TW" | "UA" | "US" | "ZA" | "ZM" | "any"

URLOptions

URLOptions: { allowProtocolRelativeURLs?: undefined | false | true; allowTrailingDot?: undefined | false | true; allowUnderscores?: undefined | false | true; disallowAuth?: undefined | false | true; hostBlacklist?: undefined | false | true; hostWhitelist?: undefined | false | true; protocols?: string[]; requireHost?: undefined | false | true; requireProtocol?: undefined | false | true; requireTLD?: undefined | false | true; requireValidProtocol?: undefined | false | true; validateLength?: undefined | false | true }

Type declaration

  • Optional allowProtocolRelativeURLs?: undefined | false | true
  • Optional allowTrailingDot?: undefined | false | true
  • Optional allowUnderscores?: undefined | false | true
  • Optional disallowAuth?: undefined | false | true
  • Optional hostBlacklist?: undefined | false | true
  • Optional hostWhitelist?: undefined | false | true
  • Optional protocols?: string[]
  • Optional requireHost?: undefined | false | true
  • Optional requireProtocol?: undefined | false | true
  • Optional requireTLD?: undefined | false | true
  • Optional requireValidProtocol?: undefined | false | true
  • Optional validateLength?: undefined | false | true

Variables

Const alphaLocales

alphaLocales: string[] = Object.keys(alpha)

Const alphanumericLocales

alphanumericLocales: string[] = Object.keys(alphanumeric)

Const decimalLocales

decimalLocales: string[] = Object.keys(decimal)

Const fullWidth

fullWidth: RegExp = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/

Const halfWidth

halfWidth: RegExp = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/

Const mobileLocales

mobileLocales: string[] = Object.keys(phones)

Functions

Const isAfter

  • isAfter(str: string, date?: string): boolean
  • Parameters

    • str: string
    • Default value date: string = String(new Date())

    Returns boolean

Const isAlpha

  • isAlpha(str: string, locale?: string): any
  • Parameters

    • str: string
    • Default value locale: string = "en-US"

    Returns any

Const isAlphanumeric

  • isAlphanumeric(str: string, locale?: string): any
  • Parameters

    • str: string
    • Default value locale: string = "en-US"

    Returns any

Const isAscii

  • isAscii(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isBIC

  • isBIC(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isBase32

  • isBase32(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isBase64

Const isBefore

  • isBefore(str: string, date?: string): boolean
  • Parameters

    • str: string
    • Default value date: string = String(new Date())

    Returns boolean

Const isBoolean

  • isBoolean(str: string): boolean

Const isBtcAddress

  • isBtcAddress(str: string): boolean

Const isByteLength

Const isCreditCard

  • isCreditCard(str: string): boolean

Const isCurrency

Const isDataURI

  • isDataURI(str: string): boolean

Const isDate

  • isDate(input: any, format?: string): boolean
  • Parameters

    • input: any
    • Default value format: string = "YYYY/MM/DD"

    Returns boolean

Const isDecimal

Const isDivisibleBy

  • isDivisibleBy(str: string, num: string): boolean

Const isEAN

  • isEAN(str: string): boolean
  • Check if string is valid EAN: Matches EAN-8/EAN-13 regex Has valid check digit.

    Parameters

    • str: string

    Returns boolean

Const isEmail

  • Checks if the input is an email or not. Gives options to check emails with display names as well.

    example
    import {segno} from 'https://deno.land/x/segno/mod.ts';
    
    segno.isEmail('foo@bar.com'); // true
    segno.isEmail('multiple..dots@stillinvalid.com'); // false

    Parameters

    Returns boolean

Const isEmpty

Const isEthereumAddress

  • isEthereumAddress(str: string): boolean

Const isFQDN

Const isFloat

Const isFullWidth

  • isFullWidth(str: string): boolean

Const isHSL

  • isHSL(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isHalfWidth

  • isHalfWidth(str: string): boolean

Const isHash

  • isHash(str: string, algorithm: Algorithm): boolean

Const isHexColor

  • isHexColor(str: string): boolean

Const isHexadecimal

  • isHexadecimal(str: string): boolean

Const isIBAN

  • isIBAN(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isIMEI

Const isIP

  • isIP(str: string, ipVersion?: string | number): boolean
  • Parameters

    • str: string
    • Optional ipVersion: string | number

    Returns boolean

Const isIPRange

  • isIPRange(str: string): boolean

Const isISBN

  • isISBN(str: string, version?: undefined | number): boolean
  • Parameters

    • str: string
    • Optional version: undefined | number

    Returns boolean

Const isISIN

  • isISIN(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isISO31661Alpha2

  • isISO31661Alpha2(str: string): any

Const isISO31661Alpha3

  • isISO31661Alpha3(str: string): any

Const isISO8601

Const isISRC

  • isISRC(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isISSN

Const isIdentityCard

Const isIn

  • isIn(str: string, options?: any): any
  • Parameters

    • str: string
    • Optional options: any

    Returns any

Const isInt

  • isInt(str: string, options?: IntOptions): boolean

Const isJSON

Const isJWT

  • isJWT(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isLatLong

Const isLength

Const isLocale

  • isLocale(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isLowercase

  • isLowercase(str: string): boolean

Const isMACAddress

Const isMD5

  • isMD5(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isMagnetURI

  • isMagnetURI(url: string): boolean

Const isMimeType

  • isMimeType(str: string): boolean

Const isMobilePhone

Const isMongoId

  • isMongoId(str: string): boolean

Const isMultibyte

  • isMultibyte(str: string): boolean

Const isNumeric

Const isOctal

  • isOctal(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isPassportNumber

  • isPassportNumber(str: string, countryCode: CountryCode): boolean
  • Check if str is a valid passport number relative to provided ISO Country Code.

    Parameters

    Returns boolean

Const isPort

  • isPort(str: string): any
  • Parameters

    • str: string

    Returns any

Const isPostalCode

  • isPostalCode(str: string, locale: PostalCode): any

Const isRFC3339

  • isRFC3339(str: string): boolean

Const isRgbColor

  • isRgbColor(str: string, includePercentValues?: boolean): boolean
  • Parameters

    • str: string
    • Default value includePercentValues: boolean = true

    Returns boolean

Const isSemVer

  • isSemVer(str: string): any

Const isSlug

  • isSlug(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Const isSurrogatePair

  • isSurrogatePair(str: string): boolean

Const isSvg

  • isSvg(str: string): boolean
  • example
    import {segno} from 'https://deno.land/x/segno/mod.ts';
    
    segno.isSvg('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY Smile " <rect x='.5' y='.5' width='29' height='39' fill='black' stroke='red'/> <g transform='translate(0, 5)'> <circle cx='15' cy='15' r='10' fill='yellow'/><circle cx='12' cy='12' r='1.5' fill='black'/><circle cx='17' cy='12' r='1.5' fill='black'/><path d='M 10 19 L 15 23 20 19' stroke='black' stroke-width='2'/></g>"> ]>
    <svg width="850px" height="700px" version="1.1" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(16,0,0,16,0,0)">&Smile;</g></svg>'); // true
    segno.isSvg('this string ends with an svg <svg></svg>'); // false

    Parameters

    • str: string

    Returns boolean

Const isTaxID

  • isTaxID(str: string, locale?: string): boolean
  • Parameters

    • str: string
    • Default value locale: string = "en-US"

    Returns boolean

Const isURL

  • isURL(url: string, options?: URLOptions): boolean

Const isUUID

  • isUUID(str: string, version?: 3 | 4 | 5 | "all"): any
  • Parameters

    • str: string
    • Default value version: 3 | 4 | 5 | "all" = "all"

    Returns any

Const isUppercase

  • isUppercase(str: string): boolean

Const isVariableWidth

  • isVariableWidth(str: string): any

Const isWhitelisted

  • isWhitelisted(str: string, chars: string[]): boolean

Legend

Generated using TypeDoc