|
14 | 14 |
|
15 | 15 | ---@class User.Check.Value
|
16 | 16 | --- Checks whether a value is `nil`, i.e. non existant or explicitly set as nil
|
| 17 | +--- --- |
17 | 18 | --- ## Parameters
|
18 | 19 | ---
|
19 |
| ---- * `var`: Any data type to be checked if it's nil. |
20 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
21 |
| ---- Otherwise it will be flagged as non-existant and the function will return `true` |
22 |
| ---- |
23 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
24 |
| ---- If set to `true`, every element of the table will be checked. |
25 |
| ---- If **any** element doesn't exist or is `nil`, the function automatically returns false |
| 20 | +--- - `var`: Any data type to be checked if it's nil. |
| 21 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 22 | +--- Otherwise it will be flagged as non-existant and the function will return `true` |
26 | 23 | ---
|
| 24 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 25 | +--- If set to `true`, every element of the table will be checked. |
| 26 | +--- If **any** element doesn't exist or is `nil`, the function automatically returns false |
| 27 | +--- --- |
27 | 28 | --- ## Return
|
| 29 | +--- |
28 | 30 | --- A boolean value indicating whether the data is `nil` or doesn't exist
|
29 | 31 | --- ---
|
30 | 32 | ---@field is_nil ValueFunc
|
31 | 33 | --- Checks whether a value is a string
|
| 34 | +--- --- |
32 | 35 | --- ## Parameters
|
33 | 36 | ---
|
34 |
| ---- * `var`: Any data type to be checked if it's a string. |
35 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
36 |
| ---- Otherwise it will be flagged as a non-string and the function will return `false` |
37 |
| ---- |
38 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
39 |
| ---- If set to `true`, every element of the table will be checked. |
40 |
| ---- If **any** element is not a string, the function automatically returns false |
| 37 | +--- - `var`: Any data type to be checked if it's a string. |
| 38 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 39 | +--- Otherwise it will be flagged as a non-string and the function will return `false`. |
41 | 40 | ---
|
| 41 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 42 | +--- If set to `true`, every element of the table will be checked. |
| 43 | +--- If **any** element is not a string, the function automatically returns false. |
| 44 | +--- --- |
42 | 45 | --- ## Return
|
43 |
| ---- A boolean value indicating whether the data is a string or not |
| 46 | +--- |
| 47 | +--- A boolean value indicating whether the data is a string or not. |
44 | 48 | --- ---
|
45 | 49 | ---@field is_str ValueFunc
|
46 | 50 | --- Checks whether a value is a table
|
| 51 | +--- --- |
47 | 52 | --- ## Parameters
|
48 | 53 | ---
|
49 |
| ---- * `var`: Any data type to be checked if it's a table. |
50 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
51 |
| ---- Otherwise it will be flagged as a non-table and the function will return `false` |
52 |
| ---- |
53 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
54 |
| ---- If set to `true`, every element of the table will be checked. |
55 |
| ---- If **any** element is not a table, the function automatically returns false |
| 54 | +--- - `var`: Any data type to be checked if it's a table. |
| 55 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 56 | +--- Otherwise it will be flagged as a non-table and the function will return `false`. |
56 | 57 | ---
|
| 58 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 59 | +--- If set to `true`, every element of the table will be checked. |
| 60 | +--- If **any** element is not a table, the function automatically returns false. |
| 61 | +--- --- |
57 | 62 | --- ## Return
|
58 |
| ---- A boolean value indicating whether the data is a table or not |
| 63 | +--- |
| 64 | +--- A boolean value indicating whether the data is a table or not. |
59 | 65 | --- ---
|
60 | 66 | ---@field is_tbl ValueFunc
|
61 | 67 | --- Checks whether a value is a number
|
| 68 | +--- --- |
62 | 69 | --- ## Parameters
|
63 | 70 | ---
|
64 |
| ---- * `var`: Any data type to be checked if it's a number. |
65 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
66 |
| ---- Otherwise it will be flagged as a non-number and the function will return `false` |
67 |
| ---- |
68 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
69 |
| ---- If set to `true`, every element of the table will be checked. |
70 |
| ---- If **any** element is not a number, the function automatically returns false |
| 71 | +--- - `var`: Any data type to be checked if it's a number. |
| 72 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 73 | +--- Otherwise it will be flagged as a non-number and the function will return `false`. |
71 | 74 | ---
|
| 75 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 76 | +--- If set to `true`, every element of the table will be checked. |
| 77 | +--- If **any** element is not a number, the function automatically returns false. |
| 78 | +--- --- |
72 | 79 | --- ## Return
|
73 |
| ---- A boolean value indicating whether the data is a number or not |
| 80 | +--- |
| 81 | +--- A boolean value indicating whether the data is a number or not. |
74 | 82 | --- ---
|
75 | 83 | ---@field is_num ValueFunc
|
76 | 84 | --- Checks whether a value is a function
|
| 85 | +--- --- |
77 | 86 | --- ## Parameters
|
78 | 87 | ---
|
79 |
| ---- * `var`: Any data type to be checked if it's a function. |
80 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
81 |
| ---- Otherwise it will be flagged as a non-function and the function will return `false` |
82 |
| ---- |
83 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
84 |
| ---- If set to `true`, every element of the table will be checked. |
85 |
| ---- If **any** element is not a function, the function automatically returns false |
| 88 | +--- - `var`: Any data type to be checked if it's a function. |
| 89 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 90 | +--- Otherwise it will be flagged as a non-function and the function will return `false`. |
86 | 91 | ---
|
| 92 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 93 | +--- If set to `true`, every element of the table will be checked. |
| 94 | +--- If **any** element is not a function, the function automatically returns false. |
| 95 | +--- --- |
87 | 96 | --- ## Return
|
88 |
| ---- A boolean value indicating whether the data is a function or not |
| 97 | +--- |
| 98 | +--- A boolean value indicating whether the data is a function or not. |
89 | 99 | --- ---
|
90 | 100 | ---@field is_fun ValueFunc
|
91 | 101 | --- Checks whether a value is a boolean
|
| 102 | +--- --- |
92 | 103 | --- ## Parameters
|
93 | 104 | ---
|
94 |
| ---- * `var`: Any data type to be checked if it's a boolean. |
95 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
96 |
| ---- Otherwise it will be flagged as a non-boolean and the function will return `false` |
97 |
| ---- |
98 |
| ---- * `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
99 |
| ---- If set to `true`, every element of the table will be checked. |
100 |
| ---- If **any** element is not a boolean, the function automatically returns false |
| 105 | +--- - `var`: Any data type to be checked if it's a boolean. |
| 106 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 107 | +--- Otherwise it will be flagged as a non-boolean and the function will return `false`. |
101 | 108 | ---
|
| 109 | +--- - `multiple`: Tell the function you're checking for multiple values. (Default: `false`). |
| 110 | +--- If set to `true`, every element of the table will be checked. |
| 111 | +--- If **any** element is not a boolean, the function automatically returns false. |
| 112 | +--- --- |
102 | 113 | --- ## Return
|
103 |
| ---- A boolean value indicating whether the data is a boolean or not |
| 114 | +--- |
| 115 | +--- A boolean value indicating whether the data is a boolean or not. |
104 | 116 | --- ---
|
105 | 117 | ---@field is_bool ValueFunc
|
106 |
| ---- Checks whether a value is an integer i.e. _greater than or equal to `0` and a **whole number**_ |
| 118 | +--- Checks whether a value is an integer i.e. _greater than or equal to `0` and a **whole number**_. |
| 119 | +--- --- |
107 | 120 | --- ## Parameters
|
108 | 121 | ---
|
109 | 122 | --- * `var`: Any data type to be checked if it's an integer.
|
110 |
| ---- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
111 |
| ---- Otherwise it will be flagged as a non-integer and the function will return `false` |
112 |
| ---- |
113 |
| ---- * `multiple`: Tell the integer you're checking for multiple values. (Default: `false`). |
114 |
| ---- If set to `true`, every element of the table will be checked. |
115 |
| ---- If **any** element is not an integer, the function automatically returns false |
| 123 | +--- **Keep in mind that if `multiple` is set to `true`, this _MUST_ be a _non-empty_ table**. |
| 124 | +--- Otherwise it will be flagged as a non-integer and the function will return `false`. |
116 | 125 | ---
|
| 126 | +--- - `multiple`: Tell the integer you're checking for multiple values. (Default: `false`). |
| 127 | +--- If set to `true`, every element of the table will be checked. |
| 128 | +--- If **any** element is not an integer, the function automatically returns false. |
| 129 | +--- --- |
117 | 130 | --- ## Return
|
118 |
| ---- A boolean value indicating whether the data is an integer or not |
| 131 | +--- |
| 132 | +--- A boolean value indicating whether the data is an integer or not. |
119 | 133 | --- ---
|
120 | 134 | ---@field is_int fun(var: any, multiple: boolean?): boolean
|
121 |
| ---- Returns whether a given string/number/table is "empty", including these scenarios: |
122 |
| ---- * Is an empty string (`x == ''`) |
123 |
| ---- * Is an integer equal to zero (`x == 0`) |
124 |
| ---- * Is an empty table |
| 135 | +--- Returns whether one or more given string/number/table are **empty** |
| 136 | +--- --- |
| 137 | +--- - Scenarios included if `multiple` is `false`: |
| 138 | +--- - Is an empty string (`x == ''`) |
| 139 | +--- - Is an integer equal to zero (`x == 0`) |
| 140 | +--- - Is an empty table (`{}`) |
125 | 141 | ---
|
| 142 | +--- If `multiple` is `true` apply the above to a table of allowed values |
| 143 | +--- NOTE: **THE FUNCTION IS NOT RECURSIVE** |
| 144 | +--- --- |
126 | 145 | --- ## Parameters
|
127 |
| ---- * `v`: Must be either a string, number or a table. |
128 |
| ---- Otherwise you'll get complaints and the function will return `true` |
129 | 146 | ---
|
| 147 | +--- - `v`: Must be either a string, number or a table. |
| 148 | +--- Otherwise you'll get complaints and the function will return `true` |
| 149 | +--- |
| 150 | +--- - `multiple`: Tell the integer you're checking for multiple values. (Default: `false`). |
| 151 | +--- If set to `true`, every element of the table will be checked. |
| 152 | +--- If **any** element is not _empty_, the function automatically returns `false`. |
| 153 | +--- --- |
130 | 154 | --- ## Returns
|
131 |
| ---- A boolean indicatin whether input data is empty or not |
| 155 | +--- |
| 156 | +--- A boolean indicatin whether input data is empty or not. |
132 | 157 | --- ---
|
133 |
| ----@field empty fun(v: string|table|number): boolean |
| 158 | +---@field empty fun(v: string|table|number|(string|table|number)[], multiple: boolean?): boolean |
134 | 159 | ---@field fields fun(fields: string|integer|(string|integer)[], T: table<string|integer, any>): boolean
|
135 | 160 | ---@field tbl_values fun(values: any[], T: table, return_keys: boolean?): boolean|string|integer|(string|integer)[]
|
136 | 161 | ---@field single_type_tbl fun(type_str: Types, T: table): boolean
|
|
0 commit comments