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_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_SUBNET_MASK_BIT_PATTERN

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

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_SUBNET_MASK_BIT_PATTERN

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

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 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 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 invalidSubnetMaskMessage

invalidSubnetMaskMessage: string = "The Subnet Mask is invalid"

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 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 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 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 isValidIPv4SubnetMask

  • isValidIPv4SubnetMask(ipv4SubnetMaskString: string): [boolean, string[]]
  • Checks if given string is a valid IPv4 subnet mask

    Parameters

    • ipv4SubnetMaskString: string

      the given IPv4 subnet mask string

    Returns [boolean, string[]]

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

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 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 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 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 isValidIPv6SubnetMask

  • isValidIPv6SubnetMask(ipv6SubnetMaskString: string): [boolean, string[]]
  • Checks if given string is a valid IPv6 subnet mask

    Parameters

    • ipv6SubnetMaskString: string

      the given IPv6 subnet mask string

    Returns [boolean, string[]]

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

Static isValidPrefixValue

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

    Parameters

    • prefixValue: number

      value to check

    • ipNumType: IPNumType.ASN | IPNumType.IPv4 | IPNumType.IPv6

      The type of IP number

    Returns [boolean, string[]]

    a tuple representing if valid or not and corresponding message

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