Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Validator

Hierarchy

  • Validator

Index

Properties

Static EIGHT_BIT_SIZE

EIGHT_BIT_SIZE: BigInteger = bigInt("1".repeat(8), 2)

Static IPV4_CONTIGUOUS_MASK_BIT_PATTERN

IPV4_CONTIGUOUS_MASK_BIT_PATTERN: RegExp = new RegExp(/^(1){0,32}(0){0,32}$/)

Static IPV4_PATTERN

IPV4_PATTERN: RegExp = new RegExp(/^(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/)

Static IPV4_RANGE_PATTERN

IPV4_RANGE_PATTERN: RegExp = new RegExp(/^(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(0?[0-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/)([1-9]|[1-2][0-9]|3[0-2])$/)

Static IPV4_SIZE

IPV4_SIZE: BigInteger = bigInt("4294967296")

Static IPV6_CONTIGUOUS_MASK_BIT_PATTERN

IPV6_CONTIGUOUS_MASK_BIT_PATTERN: RegExp = new RegExp(/^(1){0,128}(0){0,128}$/)

Static IPV6_RANGE_PATTERN

IPV6_RANGE_PATTERN: RegExp = new RegExp(/^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/)

Static IPV6_SIZE

IPV6_SIZE: BigInteger = bigInt("340282366920938463463374607431768211456")

Static InvalidIPCidrRangeMessage

InvalidIPCidrRangeMessage: string = "Given IP number portion must is not the start of the range"

Static ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE

ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE: BigInteger = bigInt("1".repeat(128), 2)

Static SIXTEEN_BIT_SIZE

SIXTEEN_BIT_SIZE: BigInteger = bigInt("1".repeat(16), 2)

Static THIRTY_TWO_BIT_SIZE

THIRTY_TWO_BIT_SIZE: BigInteger = bigInt("1".repeat(32), 2)

Static cannotSplitSingleRangeErrorMessage

cannotSplitSingleRangeErrorMessage: string = "Cannot split an IP range with a single IP number"

Static invalid16BitAsnRangeMessage

invalid16BitAsnRangeMessage: string = "ASN number given less than zero or is greater than 16bit"

Static invalidAsnRangeMessage

invalidAsnRangeMessage: string = "ASN number given less than zero or is greater than 32bit"

Static invalidBinaryStringErrorMessage

invalidBinaryStringErrorMessage: string = "Binary string should contain only contiguous 1s and 0s"

Static invalidHexadecatetCountMessage

invalidHexadecatetCountMessage: string = "An IP6 number must have exactly 8 hexadecatet"

Static invalidHexadecatetMessage

invalidHexadecatetMessage: string = "The value given is less than zero or is greater than 16bit"

Static invalidIPRangeSizeForCidrMessage

invalidIPRangeSizeForCidrMessage: string = "Given size can't be created via cidr prefix"

Static invalidIPRangeSizeMessage

invalidIPRangeSizeMessage: string = "Given size is zero or greater than maximum size of $iptype"

Static invalidIPv4CidrNotationMessage

invalidIPv4CidrNotationMessage: string = "Cidr notation should be in the form [ip number]/[range]"

Static invalidIPv4NumberMessage

invalidIPv4NumberMessage: string = "IPv4 number given less than zero or is greater than 32bit"

Static invalidIPv6CidrNotationString

invalidIPv6CidrNotationString: string = "A Cidr notation string should contain an IPv6 number and prefix"

Static invalidIPv6NumberMessage

invalidIPv6NumberMessage: string = "IPv6 number given less than zero or is greater than 128bit"

Static invalidInetNumType

invalidInetNumType: string = "Given ipNumType must be either InetNumType.IPv4 or InetNumType.IPv6"

Static invalidMaskMessage

invalidMaskMessage: string = "The Mask is invalid"

Static invalidOctetCountMessage

invalidOctetCountMessage: string = "An IP4 number cannot have less or greater than 4 octets"

Static invalidOctetRangeMessage

invalidOctetRangeMessage: string = "Value given contains an invalid Octet; Value is less than zero or is greater than 8bit"

Static invalidPrefixValueMessage

invalidPrefixValueMessage: string = "A Prefix value cannot be less than 0 or greater than 32"

Static invalidRangeFirstNotGreaterThanLastMessage

invalidRangeFirstNotGreaterThanLastMessage: string = "First IP in [first ip]-[last ip] must be less than Last IP"

Static invalidRangeNotationMessage

invalidRangeNotationMessage: string = "Range notation should be in the form [first ip]-[last ip]"

Static takeOutOfRangeSizeMessage

takeOutOfRangeSizeMessage: string = "$count is greater than $size, the size of the range"

Methods

Static Private isHexadecatet

  • isHexadecatet(value: string): boolean

Static Private isNumeric

  • isNumeric(value: string): boolean

Static isValid16BitAsnNumber

  • isValid16BitAsnNumber(asnNumber: BigInteger): [boolean, string[]]
  • Checks if the given ASN number is a 16bit ASN number

    Parameters

    • asnNumber: BigInteger

      to check if 16bit or not

    Returns [boolean, string[]]

    first value is true if valid 16bit ASN, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidAsnNumber

  • isValidAsnNumber(asnNumber: BigInteger): [boolean, string[]]
  • Checks if the number given is within the value considered valid for an ASN number

    Parameters

    • asnNumber: BigInteger

      the asn number to validate

    Returns [boolean, string[]]

    first value is true if valid ASN, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidBinaryString

  • isValidBinaryString(binaryString: string): [boolean, string[]]
  • Checks if the given string is a binary string. That is contains only contiguous 1s and 0s

    Parameters

    • binaryString: string

      the binary string

    Returns [boolean, string[]]

    a tuple representing if valid or not and corresponding message

Static Private isValidCidrRange

  • isValidCidrRange(rangeString: string, cidrNotationValidator: function, toBinaryStringConverter: function, prefixFactory: function): [boolean, string[]]
  • Parameters

    • rangeString: string
    • cidrNotationValidator: function
        • (range: string): [boolean, string[]]
        • Parameters

          • range: string

          Returns [boolean, string[]]

    • toBinaryStringConverter: function
        • (range: string): string
        • Parameters

          • range: string

          Returns string

    • prefixFactory: function
        • (num: number): string
        • Parameters

          • num: number

          Returns string

    Returns [boolean, string[]]

Static isValidIPv4CidrNotation

  • isValidIPv4CidrNotation(ipv4RangeAsCidrString: string): [boolean, string[]]
  • Checks if the given string is a valid IPv4 range in Cidr notation

    Parameters

    • ipv4RangeAsCidrString: string

      the IPv4 range in Cidr notation

    Returns [boolean, string[]]

    first value is true if valid IPv4 range in Cidr notation, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv4CidrRange

  • isValidIPv4CidrRange(ipv4CidrNotation: string): [boolean, string[]]
  • Checks if the given string is a valid IPv4 range in Cidr notation, with the ip number in the cidr notation being the start of the range

    Parameters

    • ipv4CidrNotation: string

      the IPv4 range in Cidr notation

      • @returns {[boolean , string[]]} first value is true if valid Cidr notation, false otherwise. Second value contains [] or an array of error message when invalid

    Returns [boolean, string[]]

Static isValidIPv4Mask

  • isValidIPv4Mask(ipv4MaskString: string): [boolean, string[]]
  • Checks if given string is a valid IPv4 mask

    Parameters

    • ipv4MaskString: string

      the given IPv4 mask string

    Returns [boolean, string[]]

    first value is true if valid IPv4 mask string, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv4Number

  • isValidIPv4Number(ipv4Number: BigInteger): [boolean, string[]]
  • Checks if the number given is within the value considered valid for an IPv4 number

    Parameters

    • ipv4Number: BigInteger

      the asn number to validate

    Returns [boolean, string[]]

    first value is true if valid IPv4 number, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv4Octet

  • isValidIPv4Octet(octetNumber: BigInteger): [boolean, string[]]
  • Checks if the number given is valid for an IPv4 octet

    Parameters

    • octetNumber: BigInteger

      the octet value

    Returns [boolean, string[]]

    true if valid octet, false otherwise

Static isValidIPv4RangeString

  • isValidIPv4RangeString(ipv4RangeString: string): [boolean, string[]]
  • Parameters

    • ipv4RangeString: string

    Returns [boolean, string[]]

Static isValidIPv4String

  • isValidIPv4String(ipv4String: string): [boolean, string[]]
  • Checks if given string is a valid IPv4 value.

    Parameters

    • ipv4String: string

      the IPv4 string to validate

    Returns [boolean, string[]]

    result of validation, first value represents if is valid IPv4, second value contains error message if invalid IPv4

Static isValidIPv6CidrNotation

  • isValidIPv6CidrNotation(ipv6RangeAsCidrString: string): [boolean, string[]]
  • Checks if the given string is a valid IPv6 range in Cidr notation

    Parameters

    • ipv6RangeAsCidrString: string

      the IPv6 range in Cidr notation

    Returns [boolean, string[]]

    first value is true if valid IPv6 range in Cidr notation, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv6CidrRange

  • isValidIPv6CidrRange(ipv6CidrNotation: string): [boolean, string[]]
  • Checks if the given string is a valid IPv6 range in Cidr notation, with the ip number in the cidr notation being the start of the range

    Parameters

    • ipv6CidrNotation: string

      the IPv6 range in Cidr notation

      • @returns {[boolean , string[]]} first value is true if valid Cidr notation, false otherwise. Second value contains [] or an array of error message when invalid

    Returns [boolean, string[]]

Static isValidIPv6Hexadecatet

  • isValidIPv6Hexadecatet(hexadecatetNum: BigInteger): [boolean, string[]]
  • Checks if the number given is valid for an IPv6 hexadecatet

    Parameters

    • hexadecatetNum: BigInteger

      the hexadecatet value

    Returns [boolean, string[]]

    first value is true if valid hexadecatet, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv6Mask

  • isValidIPv6Mask(ipv6MaskString: string): [boolean, string[]]
  • Checks if given string is a valid IPv6 mask

    Parameters

    • ipv6MaskString: string

      the given IPv6 mask string

    Returns [boolean, string[]]

    first value is true if valid IPv6 mask string, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv6Number

  • isValidIPv6Number(ipv6Number: BigInteger): [boolean, string[]]
  • Checks if the number given is within the value considered valid for an IPv6 number

    Parameters

    • ipv6Number: BigInteger

      the asn number to validate

    Returns [boolean, string[]]

    first value is true if valid IPv6 number, false otherwise. Second value contains "valid" or an error message when value is invalid

Static isValidIPv6RangeString

  • isValidIPv6RangeString(ipv6RangeString: string): [boolean, string[]]
  • Parameters

    • ipv6RangeString: string

    Returns [boolean, string[]]

Static isValidIPv6String

  • isValidIPv6String(ipv6String: string): [boolean, string[]]
  • Checks if given string is a valid IPv6 value.

    Parameters

    • ipv6String: string

      the IPv6 string to validate

    Returns [boolean, string[]]

    result of validation, first value represents if is valid IPv6, second value contains error message if invalid IPv6

Static isValidPrefixValue

  • isValidPrefixValue(prefixValue: number, ipNumType: IPNumType): [boolean, string[]]
  • Checks if given value is a valid prefix value

    Parameters

    • prefixValue: number

      value to check

    • ipNumType: IPNumType

      The type of IP number

    Returns [boolean, string[]]

    a tuple representing if valid or not and corresponding message

Static Private isValidRange

  • isValidRange(rangeString: string, validator: function, firstLastValidator: function): [boolean, string[]]
  • Parameters

    • rangeString: string
    • validator: function
        • (x: string): [boolean, string[]]
        • Parameters

          • x: string

          Returns [boolean, string[]]

    • firstLastValidator: function
        • (first: string, last: string): boolean
        • Parameters

          • first: string
          • last: string

          Returns boolean

    Returns [boolean, string[]]

Static Private isWithinRange

  • isWithinRange(ipNumber: BigInteger, lowerBound: BigInteger, upperBound: BigInteger): boolean
  • Checks if given ipNumber is in between the given lower and upper bound

    Parameters

    • ipNumber: BigInteger

      ipNumber to check

    • lowerBound: BigInteger

      lower bound

    • upperBound: BigInteger

      upper bound

    Returns boolean

    true if ipNumber is between lower and upper bound

Generated using TypeDoc