ts_ids_core.base.ids_field module

IdsField(default: Any = IdsUndefined, primary_key: str | None = None, **kwargs: Any) Any[source]

Wrap the pydantic.Field() function such that, fields default to a sentinel value for undefined (a.k.a. unknown or missing) values. As such, the field definition is compatible with schema defined using ts_ids_core.base.ids_element.IdsElement.

Parameters:
  • default – The default value to use for the field. Default set to a global instance of ts_ids_core.base.ids_undefined_type.IdsUndefinedType that’s intended to be used as a singleton.

  • primary_key – A JSON pointer to the primary key which this foreign key links to. For example, IdsField(primary_key=”/properties/samples/items/properties/pk”) would be used to define a foreign key which points to samples[*].pk. This pointer is validated when the IdsElement.schema method is called, validation fails if the target primary key field is not in the schema.

  • kwargs – All other keyword arguments are passed to pydantic.Field().

Returns:

The resulting pydantic.fields.FieldInfo produced by pydantic.Field().