Skip to content

Schema

The Table Schema model allows to manipulate a Pydantic model in Python according to the Table Schema specification

Usage

from dplib.models import Schema, IntegerField

schema = Schema()
schema.add_field(IntegerField(name='id'))
schema.missingValues = ['-']
print(schema.to_text(format="json"))
{
  "fields": [
    {
      "name": "id",
      "type": "integer"
    }
  ],
  "missingValues": ["-"]
}

Reference

dplib.models.Schema

Bases: Model

Table Schema model

Source code in dplib/models/schema/schema.py
class Schema(Model):
    """Table Schema model"""

    profile: str = pydantic.Field(
        default=settings.PROFILE_CURRENT_SCHEMA,
        alias="$schema",
    )
    """A profile URL"""

    #  name: Optional[str] = None
    """
    A simple name or identifier as for Data Package
    """

    #  title: Optional[str] = None
    """
    A string providing a title or one sentence description for this schema
    """

    #  description: Optional[str] = None
    """
    A description of the schema. The description MUST be markdown formatted —
    this also allows for simple plain text as plain text is itself valid markdown.
    """

    #  homepage: Optional[str] = None
    """
    A URL for the home on the web that is related to this data package.
    """

    #  keywords: List[str] = []
    """
    The `keywords` property is a list of short keywords related to the schema.
    """

    #  examples: List[dict[str, str]] = []
    """
    The `examples` property contains links to example data resources.
    """

    #  version: Optional[str] = None
    """
    The `version` property stores the version of the schema
    """

    #  contributors: List[Contributor] = []
    """
    The people or organizations who contributed to this Table Schema.
    """

    fields: List[IField] = []
    """
    List of fields in the table schema
    """

    fieldsMatch: Optional[IFieldsMatch] = "exact"
    """
    The way Table Schema fields are mapped onto the data source fields
    are defined by the fieldsMatch property.
    """

    missingValues: IMissingValues = [""]
    """
    A list of field values to consider as null values
    """

    primaryKey: List[str] = []
    """
    A primary key is a field or set of fields that uniquely identifies
    each row in the table.
    """

    uniqueKeys: List[List[str]] = []
    """
    A unique key is a field or a set of fields that are required
    to have unique logical values in each row in the table.
    """

    foreignKeys: List[ForeignKey] = []
    """
    A foreign key is a reference where values in a field (or fields)
    on the table (‘resource’ in data package terminology) described by this Table Schema
    connect to values a field (or fields) on this or a separate table (resource).
    """

    # Getters

    def get_field(self, *, name: Optional[str] = None) -> Optional[IField]:
        """Get a field by name

        Parameters:
            name: The name of the field to get

        Returns:
            The field with the given name if found
        """
        for field in self.fields:
            if name and field.name == name:
                return field

    def get_field_names(self) -> List[str]:
        """Get the names of the fields in the schema

        Returns:
            The names of the fields in the schema
        """
        names: List[str] = []
        for field in self.fields:
            names.append(field.name or "")
        return names

    def get_field_types(self) -> List[str]:
        """Get the types of the fields in the schema

        Returns:
            The types of the fields in the schema
        """
        types: List[str] = []
        for field in self.fields:
            types.append(field.type or "any")
        return types

    # Setters

    def add_field(self, field: IField):
        """Add a field to the schema

        Parameters:
            field: The field to add
        """
        self.fields.append(field)

    # Converters

    def to_dict(self):
        data = {"$schema": settings.PROFILE_CURRENT_SCHEMA}
        data.update(super().to_dict())
        return data

    # Compat

    @pydantic.model_validator(mode="before")
    @classmethod
    def compat(cls, data: types.IDict):
        if not isinstance(data, dict):  # type: ignore
            return data

        # schema.primaryKey
        primaryKey = data.get("primaryKey", None)
        if isinstance(primaryKey, str):
            data["primaryKey"] = [primaryKey]

        return data

fields: List[IField] = [] class-attribute instance-attribute

List of fields in the table schema

fieldsMatch: Optional[IFieldsMatch] = 'exact' class-attribute instance-attribute

The way Table Schema fields are mapped onto the data source fields are defined by the fieldsMatch property.

foreignKeys: List[ForeignKey] = [] class-attribute instance-attribute

A foreign key is a reference where values in a field (or fields) on the table (‘resource’ in data package terminology) described by this Table Schema connect to values a field (or fields) on this or a separate table (resource).

missingValues: IMissingValues = [''] class-attribute instance-attribute

A list of field values to consider as null values

primaryKey: List[str] = [] class-attribute instance-attribute

A primary key is a field or set of fields that uniquely identifies each row in the table.

profile: str = pydantic.Field(default=settings.PROFILE_CURRENT_SCHEMA, alias='$schema') class-attribute instance-attribute

A profile URL

uniqueKeys: List[List[str]] = [] class-attribute instance-attribute

A unique key is a field or a set of fields that are required to have unique logical values in each row in the table.

add_field(field)

Add a field to the schema

Parameters:

Name Type Description Default
field IField

The field to add

required
Source code in dplib/models/schema/schema.py
def add_field(self, field: IField):
    """Add a field to the schema

    Parameters:
        field: The field to add
    """
    self.fields.append(field)

compat(data) classmethod

Source code in dplib/models/schema/schema.py
@pydantic.model_validator(mode="before")
@classmethod
def compat(cls, data: types.IDict):
    if not isinstance(data, dict):  # type: ignore
        return data

    # schema.primaryKey
    primaryKey = data.get("primaryKey", None)
    if isinstance(primaryKey, str):
        data["primaryKey"] = [primaryKey]

    return data

get_field(*, name=None)

Get a field by name

Parameters:

Name Type Description Default
name Optional[str]

The name of the field to get

None

Returns:

Type Description
Optional[IField]

The field with the given name if found

Source code in dplib/models/schema/schema.py
def get_field(self, *, name: Optional[str] = None) -> Optional[IField]:
    """Get a field by name

    Parameters:
        name: The name of the field to get

    Returns:
        The field with the given name if found
    """
    for field in self.fields:
        if name and field.name == name:
            return field

get_field_names()

Get the names of the fields in the schema

Returns:

Type Description
List[str]

The names of the fields in the schema

Source code in dplib/models/schema/schema.py
def get_field_names(self) -> List[str]:
    """Get the names of the fields in the schema

    Returns:
        The names of the fields in the schema
    """
    names: List[str] = []
    for field in self.fields:
        names.append(field.name or "")
    return names

get_field_types()

Get the types of the fields in the schema

Returns:

Type Description
List[str]

The types of the fields in the schema

Source code in dplib/models/schema/schema.py
def get_field_types(self) -> List[str]:
    """Get the types of the fields in the schema

    Returns:
        The types of the fields in the schema
    """
    types: List[str] = []
    for field in self.fields:
        types.append(field.type or "any")
    return types

to_dict()

Source code in dplib/models/schema/schema.py
def to_dict(self):
    data = {"$schema": settings.PROFILE_CURRENT_SCHEMA}
    data.update(super().to_dict())
    return data

dplib.models.IFieldsMatch = Union[Literal['exact'], Literal['equal'], Literal['subset'], Literal['superset'], Literal['partial']] module-attribute

dplib.models.ForeignKey

Bases: Model

Source code in dplib/models/schema/foreignKey.py
class ForeignKey(Model):
    fields: List[str] = []
    reference: ForeignKeyReference = pydantic.Field(default_factory=ForeignKeyReference)

    # Compat

    @pydantic.model_validator(mode="before")
    @classmethod
    def compat(cls, data: types.IDict):
        if not isinstance(data, dict):  # type: ignore
            return data

        # foreignKey.fields
        fields = data.get("fields", None)
        if isinstance(fields, str):
            data["fields"] = [fields]

        return data

fields: List[str] = [] class-attribute instance-attribute

reference: ForeignKeyReference = pydantic.Field(default_factory=ForeignKeyReference) class-attribute instance-attribute

compat(data) classmethod

Source code in dplib/models/schema/foreignKey.py
@pydantic.model_validator(mode="before")
@classmethod
def compat(cls, data: types.IDict):
    if not isinstance(data, dict):  # type: ignore
        return data

    # foreignKey.fields
    fields = data.get("fields", None)
    if isinstance(fields, str):
        data["fields"] = [fields]

    return data

dplib.models.ForeignKeyReference

Bases: Model

Source code in dplib/models/schema/foreignKey.py
class ForeignKeyReference(Model):
    fields: List[str] = []
    resource: Optional[str] = None

    # Compat

    @pydantic.model_validator(mode="before")
    @classmethod
    def compat(cls, data: types.IDict):
        if not isinstance(data, dict):  # type: ignore
            return data

        # foreignKey.reference.fields
        fields = data.get("fields", None)
        if isinstance(fields, str):
            data["fields"] = [fields]

        return data

fields: List[str] = [] class-attribute instance-attribute

resource: Optional[str] = None class-attribute instance-attribute

compat(data) classmethod

Source code in dplib/models/schema/foreignKey.py
@pydantic.model_validator(mode="before")
@classmethod
def compat(cls, data: types.IDict):
    if not isinstance(data, dict):  # type: ignore
        return data

    # foreignKey.reference.fields
    fields = data.get("fields", None)
    if isinstance(fields, str):
        data["fields"] = [fields]

    return data

dplib.models.BaseField

Bases: Model

Base Field

Source code in dplib/models/field/datatypes/base.py
class BaseField(Model):
    """Base Field"""

    name: Optional[str] = None
    """
    The field descriptor MUST contain a name property.
    """

    # TODO: use proper abstract type (str/Literal string don't work with subclasses)
    type: Optional[Any] = None
    """
    A field type i.e. string, number, etc
    """

    title: Optional[str] = None
    """
    A human readable label or title for the field
    """

    description: Optional[str] = None
    """
    A description for this field e.g. “The recipient of the funds”
    """

    missingValues: IMissingValues = [""]
    """
    A list of field values to consider as null values
    """

    # This method ensures that type is not omitted as defaults in model_dump
    @pydantic.field_serializer("type")
    def serialize_type(self, value: str, info: Any):
        return value

    # Compat

    @pydantic.model_validator(mode="before")
    @classmethod
    def compat(cls, data: types.IDict):
        if not isinstance(data, dict):  # type: ignore
            return data

        # field.format
        format = data.get("format")
        if format:
            if format.startswith("fmt:"):
                data["format"] = format[4:]

        return data

description: Optional[str] = None class-attribute instance-attribute

A description for this field e.g. “The recipient of the funds”

missingValues: IMissingValues = [''] class-attribute instance-attribute

A list of field values to consider as null values

name: Optional[str] = None class-attribute instance-attribute

The field descriptor MUST contain a name property.

title: Optional[str] = None class-attribute instance-attribute

A human readable label or title for the field

type: Optional[Any] = None class-attribute instance-attribute

A field type i.e. string, number, etc

compat(data) classmethod

Source code in dplib/models/field/datatypes/base.py
@pydantic.model_validator(mode="before")
@classmethod
def compat(cls, data: types.IDict):
    if not isinstance(data, dict):  # type: ignore
        return data

    # field.format
    format = data.get("format")
    if format:
        if format.startswith("fmt:"):
            data["format"] = format[4:]

    return data

serialize_type(value, info)

Source code in dplib/models/field/datatypes/base.py
@pydantic.field_serializer("type")
def serialize_type(self, value: str, info: Any):
    return value

dplib.models.Field

Bases: BaseField

Field with unspecified type.

Source code in dplib/models/field/field.py
class Field(BaseField):
    """Field with unspecified type."""

    type: Literal[None] = None
    format: Optional[Literal["default"]] = None
    constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints)

constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal[None] = None class-attribute instance-attribute

dplib.models.AnyField

Bases: BaseField

The field contains values of a unspecified or mixed type.

Source code in dplib/models/field/datatypes/any.py
class AnyField(BaseField):
    """The field contains values of a unspecified or mixed type."""

    type: Literal["any"] = "any"
    format: Optional[Literal["default"]] = None
    constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints)

constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['any'] = 'any' class-attribute instance-attribute

dplib.models.ArrayField

Bases: BaseField

The field contains a valid JSON array.

Source code in dplib/models/field/datatypes/array.py
class ArrayField(BaseField):
    """The field contains a valid JSON array."""

    type: Literal["array"] = "array"
    format: Optional[Literal["default"]] = None
    constraints: JsonConstraints = pydantic.Field(default_factory=JsonConstraints)

constraints: JsonConstraints = pydantic.Field(default_factory=JsonConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['array'] = 'array' class-attribute instance-attribute

dplib.models.BooleanField

Bases: BaseField

The field contains boolean (true/false) data.

Source code in dplib/models/field/datatypes/boolean.py
class BooleanField(BaseField):
    """The field contains boolean (true/false) data."""

    type: Literal["boolean"] = "boolean"
    format: Optional[Literal["default"]] = None
    constraints: BaseConstraints[bool] = pydantic.Field(default_factory=BaseConstraints)

    trueValues: List[str] = ["true", "True", "TRUE", "1"]
    """
    Values to be interpreted as “true” for boolean fields
    """

    falseValues: List[str] = ["false", "False", "FALSE", "0"]
    """
    Values to be interpreted as “false” for boolean fields
    """

constraints: BaseConstraints[bool] = pydantic.Field(default_factory=BaseConstraints) class-attribute instance-attribute

falseValues: List[str] = ['false', 'False', 'FALSE', '0'] class-attribute instance-attribute

Values to be interpreted as “false” for boolean fields

format: Optional[Literal['default']] = None class-attribute instance-attribute

trueValues: List[str] = ['true', 'True', 'TRUE', '1'] class-attribute instance-attribute

Values to be interpreted as “true” for boolean fields

type: Literal['boolean'] = 'boolean' class-attribute instance-attribute

dplib.models.DateField

Bases: BaseField

he field contains a date without a time.

Source code in dplib/models/field/datatypes/date.py
class DateField(BaseField):
    """he field contains a date without a time."""

    type: Literal["date"] = "date"
    format: Optional[str] = None
    constraints: ValueConstraints[datetime.date] = pydantic.Field(
        default_factory=ValueConstraints
    )

constraints: ValueConstraints[datetime.date] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[str] = None class-attribute instance-attribute

type: Literal['date'] = 'date' class-attribute instance-attribute

dplib.models.DatetimeField

Bases: BaseField

The field contains a date with a time.

Source code in dplib/models/field/datatypes/datetime.py
class DatetimeField(BaseField):
    """The field contains a date with a time."""

    type: Literal["datetime"] = "datetime"
    format: Optional[str] = None
    constraints: ValueConstraints[datetime.datetime] = pydantic.Field(
        default_factory=ValueConstraints
    )

constraints: ValueConstraints[datetime.datetime] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[str] = None class-attribute instance-attribute

type: Literal['datetime'] = 'datetime' class-attribute instance-attribute

dplib.models.DurationField

Bases: BaseField

The field contains a duration of time.

Source code in dplib/models/field/datatypes/duration.py
class DurationField(BaseField):
    """The field contains a duration of time."""

    type: Literal["duration"] = "duration"
    format: Optional[Literal["default"]] = None
    constraints: ValueConstraints[str] = pydantic.Field(default_factory=ValueConstraints)

constraints: ValueConstraints[str] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['duration'] = 'duration' class-attribute instance-attribute

dplib.models.GeojsonField

Bases: BaseField

The field contains a JSON object according to GeoJSON or TopoJSON spec.

Source code in dplib/models/field/datatypes/geojson.py
class GeojsonField(BaseField):
    """The field contains a JSON object according to GeoJSON or TopoJSON spec."""

    type: Literal["geojson"] = "geojson"
    format: Optional[IGeojsonFormat] = None
    constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints)

constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints) class-attribute instance-attribute

format: Optional[IGeojsonFormat] = None class-attribute instance-attribute

type: Literal['geojson'] = 'geojson' class-attribute instance-attribute

dplib.models.GeopointField

Bases: BaseField

The field contains data describing a geographic point.

Source code in dplib/models/field/datatypes/geopoint.py
class GeopointField(BaseField):
    """The field contains data describing a geographic point."""

    type: Literal["geopoint"] = "geopoint"
    format: Optional[IGeojsonFormat] = None
    constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints)

constraints: BaseConstraints[str] = pydantic.Field(default_factory=BaseConstraints) class-attribute instance-attribute

format: Optional[IGeojsonFormat] = None class-attribute instance-attribute

type: Literal['geopoint'] = 'geopoint' class-attribute instance-attribute

dplib.models.IntegerField

Bases: BaseField

The field contains integers - that is whole numbers.

Source code in dplib/models/field/datatypes/integer.py
class IntegerField(BaseField):
    """The field contains integers - that is whole numbers."""

    type: Literal["integer"] = "integer"
    format: Optional[Literal["default"]] = None
    constraints: ValueConstraints[int] = pydantic.Field(default_factory=ValueConstraints)

    categories: Optional[ICategories] = None
    """
    Property to restrict the field to a finite set of possible values
    """

    categoriesOrdered: bool = False
    """
    When categoriesOrdered is true, implementations SHOULD regard the order of
    appearance of the values in the categories property as their natural order.
    """

    groupChar: Optional[str] = None
    """
    String whose value is used to group digits for integer/number fields
    """

    bareNumber: bool = True
    """
    If false leading and trailing non numbers will be removed for integer/number fields
    """

bareNumber: bool = True class-attribute instance-attribute

If false leading and trailing non numbers will be removed for integer/number fields

categories: Optional[ICategories] = None class-attribute instance-attribute

Property to restrict the field to a finite set of possible values

categoriesOrdered: bool = False class-attribute instance-attribute

When categoriesOrdered is true, implementations SHOULD regard the order of appearance of the values in the categories property as their natural order.

constraints: ValueConstraints[int] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

groupChar: Optional[str] = None class-attribute instance-attribute

String whose value is used to group digits for integer/number fields

type: Literal['integer'] = 'integer' class-attribute instance-attribute

dplib.models.ListField

Bases: BaseField

The field contains data that is an ordered one-level depth collection of primitive values with a fixed item type.

Source code in dplib/models/field/datatypes/list.py
class ListField(BaseField):
    """The field contains data that is an ordered
    one-level depth collection of primitive values with a fixed item type.
    """

    type: Literal["list"] = "list"
    format: Optional[Literal["default"]] = None
    constraints: CollectionConstraints = pydantic.Field(
        default_factory=CollectionConstraints
    )

    delimiter: Optional[str] = None
    """
    Specifies the character sequence which separates lexically represented list items.
    """

    itemType: Optional[IItemType] = None
    """
    Specifies the list item type in terms of existent Table Schema types.
    """

constraints: CollectionConstraints = pydantic.Field(default_factory=CollectionConstraints) class-attribute instance-attribute

delimiter: Optional[str] = None class-attribute instance-attribute

Specifies the character sequence which separates lexically represented list items.

format: Optional[Literal['default']] = None class-attribute instance-attribute

itemType: Optional[IItemType] = None class-attribute instance-attribute

Specifies the list item type in terms of existent Table Schema types.

type: Literal['list'] = 'list' class-attribute instance-attribute

dplib.models.NumberField

Bases: BaseField

The field contains numbers of any kind including decimals.

Source code in dplib/models/field/datatypes/number.py
class NumberField(BaseField):
    """The field contains numbers of any kind including decimals."""

    type: Literal["number"] = "number"
    format: Optional[Literal["default"]] = None
    constraints: ValueConstraints[float] = pydantic.Field(
        default_factory=ValueConstraints
    )

    decimalChar: str = "."
    """
    String whose value is used to represent a decimal point for number fields
    """

    groupChar: Optional[str] = None
    """
    String whose value is used to group digits for integer/number fields
    """

    bareNumber: bool = True
    """
    If false leading and trailing non numbers will be removed for integer/number fields
    """

bareNumber: bool = True class-attribute instance-attribute

If false leading and trailing non numbers will be removed for integer/number fields

constraints: ValueConstraints[float] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

decimalChar: str = '.' class-attribute instance-attribute

String whose value is used to represent a decimal point for number fields

format: Optional[Literal['default']] = None class-attribute instance-attribute

groupChar: Optional[str] = None class-attribute instance-attribute

String whose value is used to group digits for integer/number fields

type: Literal['number'] = 'number' class-attribute instance-attribute

dplib.models.ObjectField

Bases: BaseField

The field contains a valid JSON object.

Source code in dplib/models/field/datatypes/object.py
class ObjectField(BaseField):
    """The field contains a valid JSON object."""

    type: Literal["object"] = "object"
    format: Optional[Literal["default"]] = None
    constraints: JsonConstraints = pydantic.Field(default_factory=JsonConstraints)

constraints: JsonConstraints = pydantic.Field(default_factory=JsonConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['object'] = 'object' class-attribute instance-attribute

dplib.models.StringField

Bases: BaseField

The field contains strings, that is, sequences of characters.

Source code in dplib/models/field/datatypes/string.py
class StringField(BaseField):
    """The field contains strings, that is, sequences of characters."""

    type: Literal["string"] = "string"
    format: Optional[IStringFormat] = None
    constraints: StringConstraints = pydantic.Field(default_factory=StringConstraints)

    categories: Optional[ICategories] = None
    """
    Property to restrict the field to a finite set of possible values
    """

    categoriesOrdered: bool = False
    """
    When categoriesOrdered is true, implementations SHOULD regard the order of
    appearance of the values in the categories property as their natural order.
    """

categories: Optional[ICategories] = None class-attribute instance-attribute

Property to restrict the field to a finite set of possible values

categoriesOrdered: bool = False class-attribute instance-attribute

When categoriesOrdered is true, implementations SHOULD regard the order of appearance of the values in the categories property as their natural order.

constraints: StringConstraints = pydantic.Field(default_factory=StringConstraints) class-attribute instance-attribute

format: Optional[IStringFormat] = None class-attribute instance-attribute

type: Literal['string'] = 'string' class-attribute instance-attribute

dplib.models.TimeField

Bases: BaseField

The field contains a time without a date.

Source code in dplib/models/field/datatypes/time.py
class TimeField(BaseField):
    """The field contains a time without a date."""

    type: Literal["time"] = "time"
    format: Optional[str] = None
    constraints: ValueConstraints[datetime.time] = pydantic.Field(
        default_factory=ValueConstraints
    )

constraints: ValueConstraints[datetime.time] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[str] = None class-attribute instance-attribute

type: Literal['time'] = 'time' class-attribute instance-attribute

dplib.models.YearField

Bases: BaseField

The field contains a calendar year.

Source code in dplib/models/field/datatypes/year.py
class YearField(BaseField):
    """The field contains a calendar year."""

    type: Literal["year"] = "year"
    format: Optional[Literal["default"]] = None
    constraints: ValueConstraints[int] = pydantic.Field(default_factory=ValueConstraints)

constraints: ValueConstraints[int] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['year'] = 'year' class-attribute instance-attribute

dplib.models.YearmonthField

Bases: BaseField

The field contains a specific month of a specific year.

Source code in dplib/models/field/datatypes/yearmonth.py
class YearmonthField(BaseField):
    """The field contains a specific month of a specific year."""

    type: Literal["yearmonth"] = "yearmonth"
    format: Optional[Literal["default"]] = None
    constraints: ValueConstraints[str] = pydantic.Field(default_factory=ValueConstraints)

constraints: ValueConstraints[str] = pydantic.Field(default_factory=ValueConstraints) class-attribute instance-attribute

format: Optional[Literal['default']] = None class-attribute instance-attribute

type: Literal['yearmonth'] = 'yearmonth' class-attribute instance-attribute

dplib.models.BaseConstraints

Bases: Model, Generic[NativeType]

Source code in dplib/models/field/constraints/base.py
class BaseConstraints(Model, Generic[NativeType]):
    required: Optional[bool] = None
    unique: Optional[bool] = None
    enum: Optional[List[Union[str, NativeType]]] = None

enum: Optional[List[Union[str, NativeType]]] = None class-attribute instance-attribute

required: Optional[bool] = None class-attribute instance-attribute

unique: Optional[bool] = None class-attribute instance-attribute

dplib.models.CollectionConstraints

Bases: BaseConstraints[str]

Source code in dplib/models/field/constraints/collection.py
class CollectionConstraints(BaseConstraints[str]):
    minLength: Optional[int] = None
    maxLength: Optional[int] = None

maxLength: Optional[int] = None class-attribute instance-attribute

minLength: Optional[int] = None class-attribute instance-attribute

dplib.models.JsonConstraints

Bases: CollectionConstraints

Source code in dplib/models/field/constraints/json.py
class JsonConstraints(CollectionConstraints):
    jsonSchema: Optional[Dict[str, Any]] = None

jsonSchema: Optional[Dict[str, Any]] = None class-attribute instance-attribute

dplib.models.StringConstraints

Bases: CollectionConstraints

Source code in dplib/models/field/constraints/string.py
class StringConstraints(CollectionConstraints):
    pattern: Optional[str] = None

pattern: Optional[str] = None class-attribute instance-attribute

dplib.models.ValueConstraints

Bases: BaseConstraints[NativeType], Generic[NativeType]

Source code in dplib/models/field/constraints/value.py
class ValueConstraints(BaseConstraints[NativeType], Generic[NativeType]):
    minimum: Optional[Union[str, NativeType]] = None
    maximum: Optional[Union[str, NativeType]] = None
    exclusiveMinimum: Optional[Union[str, NativeType]] = None
    exclusiveMaximum: Optional[Union[str, NativeType]] = None

exclusiveMaximum: Optional[Union[str, NativeType]] = None class-attribute instance-attribute

exclusiveMinimum: Optional[Union[str, NativeType]] = None class-attribute instance-attribute

maximum: Optional[Union[str, NativeType]] = None class-attribute instance-attribute

minimum: Optional[Union[str, NativeType]] = None class-attribute instance-attribute