Docs/API reference

DatasetSchema · Python

Validate required fields and canonicalize string values in small Dataset results.

Download .md
Developers2 min read8 sections
Source reference · Match your SDK version. Availability and known issues
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 DatasetSchema
python1 lines · copy-ready

Usage 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"}))
python3 lines · copy-ready

Members

MemberKindReturn / value typeSource status
__init__methodNot annotated; see behavior notesPresent in source
add_fieldmethod'DatasetSchema'Present in source
validatemethodDict[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)
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
_core_schemaNot annotatedDefault: NoneOptional 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestrRequiredField, header or attribute name for this operation.
field_typeFieldTypeRequiredA FieldType enum member.
requiredboolRequiredWhether 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]
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
recordDict[str, str]RequiredString-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.