Validator.lua

From Alpine Linux
Jump to: navigation, search

is_ipv4 (function)

INPUT:
This library function required the following inputs/parameters.

  • String in form of ip address
    • Example: 192.168.24.10

OUTPUT:
This library function deliverers the following output/parameters.

  • false or "true"

CODING EXAMPLE:

-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_ip("192.168.24.10")

If the string is a valid ip 'liboutput' would contain string:

true

If the string is missing or an invalid ip 'liboutput' would contain false.

is_mac (function)

INPUT:
This library function required the following inputs/parameters.

  • String in form of mac address
    • Example: 00:ca:ba:de:00:12

OUTPUT:
This library function deliverers the following output/parameters.

  • false or "true"

CODING EXAMPLE:

-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_mac("00:ca:ba:de:00:12")

If the string is a valid mac address 'liboutput' would contain string:

true

If the string is missing or an invalid ip 'liboutput' would contain false.

is_integer(function)

INPUT:
This library function required the following inputs/parameters.

  • Number
    • Example: 100

OUTPUT:
This library function deliverers the following output/parameters.

  • false or "true"

CODING EXAMPLE:

-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_integer("100")

If the string is a valid ip 'liboutput' would contain string:

true

If the string is missing or an invalid ip 'liboutput' would contain false.

is_integer_in_range (function)

INPUT:
This library function required the following inputs/parameters.

  • 3 numbers --- number to test, min, max
    • Example: (10,5,12)

OUTPUT:
This library function deliverers the following output/parameters.

  • false or "true"

CODING EXAMPLE:

-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_integer_in_range(10,5,15)

If the string is a valid ip 'liboutput' would contain string:

true

If the string is missing or an invalid ip 'liboutput' would contain false.

is_port (function)

INPUT:
This library function required the following inputs/parameters.

  • Number - is it between 1 and 65535
    • Example: 45

OUTPUT:
This library function deliverers the following output/parameters.

  • false or "true"

CODING EXAMPLE:

-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_port("45")

If the string is a valid ip 'liboutput' would contain string:

true

If the string is missing or an invalid ip 'liboutput' would contain false.