DatasetSchema · Python
Validate required fields and canonicalize string values in small Dataset results.
In this guide
Purpose and lifecycle
Add named constraints, then attach the schema to a Dataset or call validate on a field map.
This class is separate from DatasetJob’s JobField validation options. JobField lives in job configuration and supports required, min_length and whitespace normalization.
Definition and availability
Source snapshot: 1.0.0-alpha.3. Package export. Declared in source; this is not a runtime test result.
Signatures and source locations are generated from the SDK wrappers. Clean snapshots link to the recorded commit. Modified snapshots link to main, which may differ; file hashes identify the local inputs.
class DatasetSchemaUsage example
Use a matching source build. Where a snippet uses page, obtain it with the Page example first. Example URLs illustrate API shape; they are not promised datasets.
from crawlingo import DatasetSchema, FieldType
schema = DatasetSchema().add_field("count", FieldType.Integer, True)
print(schema.validate({"count": "42"}))Members
| Member | Kind | Return / value type | Source status |
|---|---|---|---|
| __init__ | method | Not annotated; see behavior notes | Present in source |
| add_field | method | 'DatasetSchema' | Present in source |
| validate | method | Dict[str, str] | Present in source |
__init__()
Create an empty field schema, or wrap the optional native schema in Python. Add field constraints before validating records.
Returns / value: Not annotated; see behavior notes.
def __init__(self, _core_schema=None)| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| _core_schema | Not annotated | Default: None | Optional native schema handle; omit to create an empty schema. |
add_field()
Add a named type constraint; required determines whether an empty/missing value is rejected.
Returns / value: 'DatasetSchema'.
def add_field(self, name: str, field_type: FieldType, required: bool) -> 'DatasetSchema'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| name | str | Required | Field, header or attribute name for this operation. |
| field_type | FieldType | Required | A FieldType enum member. |
| required | bool | Required | Whether an empty or missing field is rejected. |
validate()
Validate the supplied map and return canonicalized string values for declared fields.
Returns / value: Dict[str, str].
def validate(self, record: Dict[str, str]) -> Dict[str, str]| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| record | Dict[str, str] | Required | String-valued field map to validate. |
Errors and operational limits
Missing required values and invalid integer/float/boolean values fail validation. Node raises CrawlingoError; Python may expose native RuntimeError.
Source availability, package publication and runtime validation are separate facts. These pages describe the source snapshot, not a claim that all platforms or every API path have passed production acceptance.