Docs/API reference

DatasetSchema · Node.js

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

Download .md
Developers2 min read9 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.

export class DatasetSchema
typescript1 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.

import { DatasetSchema, FieldType } from 'crawlingo';
const schema = new DatasetSchema().addField('count', FieldType.Integer, true);
console.log(schema.validate({ count: '42' }));
typescript3 lines · copy-ready

Members

MemberKindReturn / value typeSource status
innerpropertyJsDatasetSchemaPresent in source
constructormethodDatasetSchemaPresent in source
addFieldmethodthisPresent in source
validatemethodRecord<string, string>Present in source

inner

Native interop handle. Prefer the documented wrapper methods; bypassing them can bypass validation and typed error conversion.

Returns / value: JsDatasetSchema.

public readonly inner: JsDatasetSchema;
typescript1 lines · copy-ready

constructor()

Create an empty field schema, or wrap the optional native schema in Python. Add field constraints before validating records.

Returns / value: DatasetSchema.

constructor(): DatasetSchema
typescript1 lines · copy-ready

addField()

Add a named type constraint; required determines whether an empty/missing value is rejected.

Returns / value: this.

addField(name: string, fieldType: FieldType, required: boolean): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestringRequiredField, header or attribute name for this operation.
fieldTypeFieldTypeRequiredA FieldType enum member.
requiredbooleanRequiredWhether an empty or missing field is rejected.

validate()

Validate the supplied map and return canonicalized string values for declared fields.

Returns / value: Record<string, string>.

validate(record: Record<string, string>): Record<string, string>
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
recordRecord<string, string>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.