Validators
chart_checkbox(value)
A validator for checkbox.
In a checkbox form snippet we have two inputs, one hidden and one checkbox. The hidden input always sends a value of "off" and the checkbox sends "on"
We need it to properly set a default True value for the field.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The checkbox(s) value(s)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
The value as a boolean
TYPE:
|
Source code in ckanext/charts/logic/validators.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
charts_if_empty_same_as(other_key)
A custom version of if_empty_same_as validator for charts.
This validator is used to set the value of a field to the value of another field if it is empty or missing.
| PARAMETER | DESCRIPTION |
|---|---|
other_key
|
The key of the field to copy the value from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[..., Any]
|
Callable[..., Any]: The validator function |
Source code in ckanext/charts/logic/validators.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
charts_list_length_validator(max_length)
A validator to check the length of a list.
| PARAMETER | DESCRIPTION |
|---|---|
max_length
|
The maximum length of the list
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[..., Any]
|
Callable[..., Any]: The validator function |
Source code in ckanext/charts/logic/validators.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
charts_list_to_csv(data)
Convert a list of strings to a CSV string.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data to convert
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The comma separated string
TYPE:
|
Source code in ckanext/charts/logic/validators.py
146 147 148 149 150 151 152 153 154 155 156 157 158 | |
charts_strategy_support(strategy)
Check if the cache strategy is supported.
| PARAMETER | DESCRIPTION |
|---|---|
strategy
|
The cache strategy
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The cache strategy if it is supported
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Invalid
|
If the cache strategy is not supported |
Source code in ckanext/charts/logic/validators.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
charts_to_list_if_string(value)
Convert a string to a list.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value to convert
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
list[Any]: The value in a list |
Source code in ckanext/charts/logic/validators.py
131 132 133 134 135 136 137 138 139 140 141 142 143 | |
charts_validate_extras(key, data, errors, context)
Validate charts settings according to the chart type and engine schema.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The key of the field
TYPE:
|
data
|
The data to validate
TYPE:
|
errors
|
The errors dict
TYPE:
|
context
|
The context
TYPE:
|
Source code in ckanext/charts/logic/validators.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
float_validator(value)
A validator for decimal numbers.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value to validate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The value as a float
TYPE:
|
Source code in ckanext/charts/logic/validators.py
12 13 14 15 16 17 18 19 20 21 22 23 24 | |