Module Validate
Validation functions
Info:
- Copyright: Copyright (c) 2013 - 2022 Snowplow Analytics Ltd
- License: Apache License Version 2.0
- Author: Alex Dean
Functions
validate.is_boolean (name, value) | Validates that a value is a boolean. |
validate.is_non_empty_table (name, value) | Validates that a value is a table. |
validate.is_table_or_nil (name, value) | Validates that a value is a table. |
validate.is_non_empty_string (name, value) | Validates that a value is a non-empty string. |
validate.is_non_empty_string_or_nil (name, value) | Validates that a value is a non-empty string, or nil. |
validate.is_string_or_nil (name, value) | Validates that a value is a string, or nil. |
validate.is_string_from_set (set, name, value) | Validates that a value is a string from a Set. |
validate.is_number (name, value) | Validates that a value is a number. |
validate.is_number_or_nil (name, value) | Validates that a value is a number, or nil. |
validate.is_positive_integer (name, value) | Validates that a value is a a positive integer. |
validate.is_type (expected_types, name, value) | Validates that a value is of a given type. |
Functions
- validate.is_boolean (name, value)
-
Validates that a value is a boolean.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a boolean
- validate.is_non_empty_table (name, value)
-
Validates that a value is a table.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a table
- validate.is_table_or_nil (name, value)
-
Validates that a value is a table.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a table
- validate.is_non_empty_string (name, value)
-
Validates that a value is a non-empty string.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a non-empty string
- validate.is_non_empty_string_or_nil (name, value)
-
Validates that a value is a non-empty string, or nil.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a non-empty string or nil
- validate.is_string_or_nil (name, value)
-
Validates that a value is a string, or nil.
Parameters:
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a string or nil
- validate.is_string_from_set (set, name, value)
-
Validates that a value is a string from a Set.
Parameters:
- set Set The set to check against
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is a string from the set
- validate.is_number (name, value)
-
Validates that a value is a number.
Parameters:
- name string The name of the value to validate
- value number The value to validate
Returns:
-
bool
Whether the value is a number
- validate.is_number_or_nil (name, value)
-
Validates that a value is a number, or nil.
Parameters:
- name string The name of the value to validate
- value number The value to validate
Returns:
-
bool
Whether the value is a number or nil
- validate.is_positive_integer (name, value)
-
Validates that a value is a a positive integer.
Parameters:
- name string The name of the value to validate
- value number The value to validate
Returns:
-
bool
Whether the value is a positive integer
- validate.is_type (expected_types, name, value)
-
Validates that a value is of a given type.
Parameters:
- expected_types tab The expected types
- name string The name of the value to validate
- value The value to validate
Returns:
-
bool
Whether the value is any of the given types