Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

BoolRField

Resource field for storing boolean values.

BoolRField stores boolean (True/False) values with automatic validation and configurable storage. By default, booleans are stored in the DATABASE for efficient querying and filtering.

This is useful for: - Feature flags and toggles - Status indicators (is_valid, is_complete, has_error) - Binary states and conditions - Configuration options

Storage behavior: - Stored in DATABASE by default (searchable and queryable) - Included in dict views by default - Automatically validated as boolean on load/save

Example: ```python class MyResource(Resource): # Simple flag is_valid = BoolRField()

    # With default value
    is_processed = BoolRField(default_value=False)

    # Stored in KV_STORE instead
    internal_flag = BoolRField(storage=RFieldStorage.KV_STORE)

    # Not included in dict view
    debug_flag = BoolRField(include_in_dict_view=False)
```
Attributes
include_in_dict_view: boolstorage: RFieldStoragevalidator: Validator
Functions
__init__

Initialize a BoolRField for storing boolean values.

default_value : bool | None
Default boolean value. Can be: - bool: True or False - Type or Callable: Called to generate default (e.g., bool for False) - None: Field has no default value Defaults to None
include_in_dict_view : bool - True
If True, included in dict/JSON representations. Defaults to True for primitive fields
storage : RFieldStorage - RFieldStorage.DATABASE
Storage backend (DATABASE for searchable, KV_STORE for simple storage, NONE for transient). Defaults to DATABASE for booleans
deserialize

Deserialize and validate a value from storage.

Validates the stored value using the field's validator before returning it.

r_field_value : Any
The raw value from storage
Return type : Any
get_default_value

Get the default value for this field.

If the default value is a Type or Callable, it will be called to generate a new default value. Otherwise, the default value is returned directly.

This ensures that mutable defaults (like lists or dicts) are not shared between Resource instances.

Return type : Any
serialize

Serialize and validate a value for storage.

Validates the value using the field's validator before storing it.

r_field_value : Any
The runtime value to serialize
Return type : Any
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.