extends JSONProperty
returns: bool
Only allows booleans.
In this example, the configuration structure has one required property. The property 'bool' must be a boolean.
# Create a JSON configuration file
var json_config_file = JSONConfigFile.new()
# Add a 'bool' property, which must be a boolean
json_config_file.add_property("bool", JSONPropertyBool.new())
# Validate input
json_config_file.validate(json_file_path)This JSON has the required field, which is a boolean:
{
"bool": true
}This JSON contains one error. The 'bool' property is not the correct type.
{
"bool": 42
}Returned error:
[
{
"error": JSONProperty.Errors.WRONG_TYPE,
"expected": JSONProperty.Types.BOOL,
"context": "bool",
"as_text": "Wrong type: expected 'boolean', at 'bool'."
}
]The public methods of this class are:
| Name | Params | Description | Returns |
|---|---|---|---|
| set_preprocessor | processor -> JSONConfigProcessor: Object that defines the function to execute before the validation process. |
Sets the process to execute before the validation process. | Nothing. |
| set_postprocessor | processor -> JSONConfigProcessor: Object that defines the function to execute after the validation process. |
Sets the process to execute after the validation process. | Nothing. |
This class could directly raise any of the following errors:
| Enum value | Description | Params | As text |
|---|---|---|---|
| WRONG_TYPE | The type of the input does not match the expected one. | expected -> int: Takes the value BOOL. |
Wrong type: expected 'boolean' |