[ Impressum ]

LiveCode NetValidatorLib

www.Rozek.de > LiveCode > NetValidatorLib
The "NetValidatorLib" is a small LiveCode [1] "Library Stack" with a series of commands and functions for the validation of numerical IP addresses, symbolic host names and email addresses.

Download and Installation

The "NetValidatorLib" is available as an unencrypted LiveCode stack and can be downloaded from here:
After downloading, just place the "NetValidatorLib" in a directory of your choice - an explicit installation is not required.

Usage Instructions

The "NetValidatorLib" has been implemented as a LiveCode "library stack" and must therefore be attached to a "MainStack" prior to its use using

start using stack "NetValidatorLib"

Appropriately, this statement is executed in the context of a preOpenStack procedure of a MainStack.

Should the MainStack later be converted into a standalone application, the "NetValidatorLib" must also become part of the list of "Stack Files" in this MainStack (this is easiest done by using the "Standalone Application Settings" from the LiveCode development environment).

Usage Instructions for mobile Applications

The "NetValidatorLib" can also be used in mobile applications. However - and unlike for standalone desktop applications - it must then be included in the list of "non-stack files" and attached to the MainStack using

start using stack (specialFolderPath("engine") & "/NetValidatorLib.livecode")

The list of "non-stack files" can likewise be found on the "Copy Files" page in the "Standalone Application Settings" of the LiveCode development environment.

Command Overview

The "NetValidatorLib" contains four groups of commands and functions:
  • commands for the validation of numerical IP addresses, symbolic host names and email addresses
    check the given values for syntactical correctness and throw an exception in the case of an error;
     
  • functions for validation of numerical IP addresses, symbolic host names and email addresses
    check the given values for syntactical correctness and return true on success or false on failure;
     
  • commands for the validation of optional arguments (allowXXX)
    check the given arguments (if any) for formal correctness and throw an exception in the case of an error;
     
  • commands to validate required arguments (expectXXX)
    check for the presence of any expected arguments and their contents for formal correctness - in case of an error, an exception is thrown.
The former group contains the actual functionality - all other commands and functions just simplify their use only.

Commands for Validation of Network-related Values

The names of the commands in this group all begin with validate. If the given argument Candidate complies to the verified syntax, the procedure finishes without further incident and the calling script may be continued. Otherwise, an appropriate exception is thrown which may be caught an processed by the calling script.

The commands are (in alphabetic order):

validateEMailAddress <Candidate>


validateEMailAddress ensures that the given Candidate contains a syntactically valid EMail address (conforming to RFC 5322 - without the "quoted-string" notations which should be avoided anyway).

validateHostName <Candidate>


validateHostName ensures that the given Candidate contains a valid DNS host name (according to RFC 1035, section 2.3.1).

validateIPAddress <Candidate>


validateIPAddress ensures that the given Candidate contains a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validateIPv4Address <Candidate>


validateIPv4Address ensures that the given Candidate contains a valid numeric IPv4 address.

validateIPv6Address <Candidate>


validateIPv6Address ensures that the given Candidate contains a valid numeric IPv6 address. It supports a variety of forms, including those with double colons and/or trailing dotted quads.

validateIPHost <Candidate>


validateIPHost ensures that the given Candidate contains either a valid DNS host name or a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validateIPv4Host <Candidate>


validateIPv4Host ensures that the given Candidate contains either a valid DNS host name or a valid numeric IPv4 address.

validateIPv6Host <Candidate>


validateIPv6Host ensures that the given Candidate contains either a valid DNS host name or a valid numeric IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validatePortNumber <Candidate>


validatePortNumber ensures that the given Candidate contains a valid port number (i.e., an integer in the range 1...65535).

Functions for Validation of Network-related Values

The names of the functions in this group all begin with valid. If the given argument Candidate complies to the verified syntax, the function finishes and returns true. Otherwise, false is returned (but no exception thrown!).

The functions are (in alphabetic order):

validEMailAddress <Candidate>


validEMailAddress checks if the given Candidate contains a syntactically valid EMail address (conforming to RFC 5322 - without the "quoted-string" notations which should be avoided anyway).


validHostName <Candidate>


validHostName checks if the given Candidate contains a valid DNS host name (according to RFC 1035, section 2.3.1).

validIPAddress <Candidate>


validIPAddress checks if the given Candidate contains a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validIPv4Address <Candidate>


validIPv4Address checks if the given Candidate contains a valid numeric IPv4 address.

validIPv6Address <Candidate>


validIPv6Address checks if the given Candidate contains a valid numeric IPv6 address. It supports a variety of forms, including those with double colons and/or trailing dotted quads.

validIPHost <Candidate>


validIPHost checks if the given Candidate contains either a valid DNS host name or a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validIPv4Host <Candidate>


validIPv4Host checks if the given Candidate contains either a valid DNS host name or a valid numeric IPv4 address.

validIPv6Host <Candidate>


validIPv6Host checks if the given Candidate contains either a valid DNS host name or a valid numeric IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads.

validPortNumber <Candidate>


validPortNumber checks if the given Candidate contains a valid port number (i.e., an integer in the range 1...65535).

Validation of optional Arguments

This group of commands (whose names begin with "allow") validates optional arguments - these procedures differ from from those validating required arguments insofar as the given argument may also be empty.

The commands are (in alphabetic order):

allowEMailAddress <ArgName>, <ArgValue>


allowEMailAddress ensures that the passed ArgValue is either absent (i.e. empty) or contains a syntactically valid EMail address (conforming to RFC 5322 - without the "quoted-string" notations which should be avoided anyway). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowHostName <ArgName>, <ArgValue>


allowHostName ensures that the passed ArgValue is either absent (i.e. empty) or contains a valid DNS host name (according to RFC 1035, section 2.3.1). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPAddress <ArgName>, <ArgValue>


allowIPAddress ensures that the passed ArgValue is either absent (i.e. empty) or contains a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPv4Address <ArgName>, <ArgValue>


allowIPv4Address ensures that the passed ArgValue is either absent (i.e. empty) or contains a valid numeric IPv4 address. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPv6Address <ArgName>, <ArgValue>


allowIPv6Address ensures that the passed ArgValue is either absent (i.e. empty) or contains a valid numeric IPv6 address. It supports a variety of forms, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPHost <ArgName>, <ArgValue>


allowIPHostensures that the passed ArgValue is either absent (i.e. empty) or contains either a valid DNS host name or a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPv4Host <ArgName>, <ArgValue>


allowIPv4Host ensures that the passed ArgValue is either absent (i.e. empty) or contains either a valid DNS host name or a valid numeric IPv4 address. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowIPv6Host <ArgName>, <ArgValue>


allowIPv6Host ensures that the passed ArgValue is either absent (i.e. empty) or contains either a valid DNS host name or a valid numeric IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

allowPortNumber <ArgName>, <ArgValue>


allowPortNumber ensures that the passed ArgValue is either absent (i.e. empty) or contains a valid port number (i.e., an integer in the range 1...65535). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

Validation of mandatory Arguments

This group of commands (whose names begin with "expect") validates mandatory arguments - these procedures differ from from those validating optional arguments insofar as the given argument may never be empty.

The commands are (in alphabetic order):

expectEMailAddress <ArgName>, <ArgValue>


expectEMailAddress ensures that the passed ArgValue exists (i.e., is not empty) and contains a syntactically valid EMail address (conforming to RFC 5322 - without the "quoted-string" notations which should be avoided anyway). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectHostName <ArgName>, <ArgValue>


expectHostName ensures that the passed ArgValue exists (i.e., is not empty) and contains a valid DNS host name (according to RFC 1035, section 2.3.1). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPAddress <ArgName>, <ArgValue>


expectIPAddress ensures that the passed ArgValue exists (i.e., is not empty) and contains a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPv4Address <ArgName>, <ArgValue>


expectIPv4Address ensures that the passed ArgValue exists (i.e., is not empty) and contains a valid numeric IPv4 address. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPv6Address <ArgName>, <ArgValue>


expectIPv6Address ensures that the passed ArgValue exists (i.e., is not empty) and contains a valid numeric IPv6 address. It supports a variety of forms, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPHost <ArgName>, <ArgValue>


expectIPHostensures that the passed ArgValue exists (i.e., is not empty) and contains either a valid DNS host name or a valid numeric IPv4 or IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPv4Host <ArgName>, <ArgValue>


expectIPv4Host ensures that the passed ArgValue exists (i.e., is not empty) and contains either a valid DNS host name or a valid numeric IPv4 address. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectIPv6Host <ArgName>, <ArgValue>


expectIPv6Host ensures that the passed ArgValue exists (i.e., is not empty) and contains either a valid DNS host name or a valid numeric IPv6 address. It supports a variety of forms of IPv6 addresses, including those with double colons and/or trailing dotted quads. ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

expectPortNumber <ArgName>, <ArgValue>


expectPortNumber ensures that the passed ArgValue exists (i.e., is not empty) and contains a valid port number (i.e., an integer in the range 1...65535). ArgName must be a syntactically correct, non-empty LiveCode identifier and is used to form a meaningful error message should an exception be thrown.

System Requirements

The "NetValidatorLib" requires LiveCode 6.x or later, and works regardless of the operating system on both stationary and mobile platforms.

Dependencies

Internally, the "NetValidatorLib" uses my "BasicLib" and the "ValidatorLib" - when using the "NetValidatorLib", these two must therefore also be present.

Automated Tests

There is also a separate stack with automated tests of the "NetValidatorLib":
When this stack is opened, the command performTests is executed, which is responsible for running the actual tests. In the end, the "Message Box" of the LiveCode development environment should appear and display the message

all tests passed

Otherwise, an error message with information about the failed test should be shown instead.

Known Bugs

There are currently no known bugs in the "NetValidatorLib".

License Information

The "NetValidatorLib" and its tests are licensed under a "Creative Commons Attribution 4.0 Unported license", which essentially means that you may both use and modify them (even in a commercial context) - provided that your changes have been marked as such and there is a reference to me as the original author at an appropriate place.

                       
Have fun with LiveCode and my libraries! Creative Commons License

Bibliography

[1]
(RunRev Ltd.)
LiveCode | Create apps for multiple platforms. Quickly. Easily. Free
LiveCode is a development environment for both stationary (Windows, Linux, MacOS X) and mobile (iOS, Android) applications modeled after the legendary Apple HyperCard. A visual editor allows fast design of user interfaces, a programming language inspired by the english language allows even non-professional programmers to develop professional applications and the concept of "modifying a running program" simplifies testing and troubleshooting.