Schema {tableschema.r}R Documentation

Schema class

Description

A model of a schema with helpful methods for working with the schema and supported data. Schema instances can be initialized with a schema source as a url to a JSON file or a JSON object. The schema is initially validated (see validate). By default validation errors will be stored in $errors but in a strict mode it will be instantly raised.

Usage

# Schema.load(descriptor, strict=FALSE)

Arguments

descriptor

schema descriptor, a JSON string, URL or file

strict

flag to alter validation behaviour:

  • if FALSE error will not be raised and all error will be collected in schema$errors

  • if TRUE any validation error will be raised immediately

Format

R6Class object.

Value

Object of R6Class .

Methods

Schema$new(descriptor = descriptor, strict = strict)

Use Schema.load to instantiate Schema class.

getField(name)

Get schema field by name.

addField(descriptor)

Add new field to schema. The schema descriptor will be validated with newly added field descriptor.

removeField(name)

Remove field resource by name. The schema descriptor will be validated after field descriptor removal.

castRow(row)

Cast row based on field types and formats.

infer(rows, headers=1)

Cast row based on field types and formats.

commit(strict)

Cast row based on field types and formats.

save(target)

Cast row based on field types and formats.

Properties

valid

Returns validation status. It always TRUE in strict mode.

errors

Returns validation errors. It always empty in strict mode.

descriptor

Returns list of schema descriptor.

primaryKey

Returns string list of schema primary key.

foreignKeys

Returns list of schema foreign keys.

fields

Returns list of Field instances.

fieldNames

Returns a list of field names.

Language

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this package documents are to be interpreted as described in RFC 2119.

See Also

Schema.load, Table Schema Specifications


[Package tableschema.r version 1.1.2 Index]