<!-- # hard line break macro for HTML -->

# fiftyone.core.validation

Validation utilities.

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Functions:**

| [`validate_image_sample`](#fiftyone.core.validation.validate_image_sample)(sample)                                  | Validates that the sample's media is an image.                                                                                                                                                                                                                     |
|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`validate_video_sample`](#fiftyone.core.validation.validate_video_sample)(sample)                                  | Validates that the sample's media is a video.                                                                                                                                                                                                                      |
| [`validate_collection`](#fiftyone.core.validation.validate_collection)(sample_collection[, ...])                    | Validates that the provided samples are a [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).                                                                                                 |
| [`validate_image_collection`](#fiftyone.core.validation.validate_image_collection)(sample_collection)               | Validates that the provided samples are an image [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).                                                                                          |
| [`validate_video_collection`](#fiftyone.core.validation.validate_video_collection)(sample_collection)               | Validates that the provided samples are a video [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).                                                                                           |
| [`validate_grouped_non_dynamic_collection`](#fiftyone.core.validation.validate_grouped_non_dynamic_collection)(...) | Validates that the provided samples are a grouped [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).                                                                                         |
| [`validate_non_grouped_collection`](#fiftyone.core.validation.validate_non_grouped_collection)(...)                 | Validates that the provided samples are a [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) that is *not* grouped.                                                                           |
| [`validate_collection_label_fields`](#fiftyone.core.validation.validate_collection_label_fields)(...[, ...])        | Validates that the [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) has fields with the specified [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types. |
| [`get_field`](#fiftyone.core.validation.get_field)(sample, field_name[, ...])                                       | Gets the given sample field and optionally validates its type and value.                                                                                                                                                                                           |
| [`get_fields`](#fiftyone.core.validation.get_fields)(sample, field_names[, ...])                                    | Gets the given sample fields and optionally validates their types and values.                                                                                                                                                                                      |

### fiftyone.core.validation.validate_image_sample(sample)

Validates that the sample’s media is an image.

* **Parameters:**
  **sample** – a [`fiftyone.core.sample.Sample`](fiftyone.core.sample.md#fiftyone.core.sample.Sample)
* **Raises:**
  **ValueError if the sample's media is not an image** – 

### fiftyone.core.validation.validate_video_sample(sample)

Validates that the sample’s media is a video.

* **Parameters:**
  **sample** – a [`fiftyone.core.sample.Sample`](fiftyone.core.sample.md#fiftyone.core.sample.Sample)
* **Raises:**
  **ValueError if the sample's media is not a video** – 

### fiftyone.core.validation.validate_collection(sample_collection, media_type=None)

Validates that the provided samples are a
[`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).

* **Parameters:**
  * **sample_collection** – a sample collection
  * **media_type** (*None*) – an optional media type or iterable of media types
    that the collection must have
* **Raises:**
  * **ValueError** – if the provided samples are not a
  * [**fiftyone.core.collections.SampleCollection**](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) – 

### fiftyone.core.validation.validate_image_collection(sample_collection)

Validates that the provided samples are an image
[`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).

* **Parameters:**
  **sample_collection** – a sample collection
* **Raises:**
  * **ValueError** – if the provided samples are not an image
  * [**fiftyone.core.collections.SampleCollection**](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) – 

### fiftyone.core.validation.validate_video_collection(sample_collection)

Validates that the provided samples are a video
[`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).

* **Parameters:**
  **sample_collection** – a sample collection
* **Raises:**
  * **ValueError** – if the provided samples are not a video
  * [**fiftyone.core.collections.SampleCollection**](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) – 

### fiftyone.core.validation.validate_grouped_non_dynamic_collection(sample_collection)

Validates that the provided samples are a grouped
[`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).

* **Parameters:**
  **sample_collection** – a sample collection
* **Raises:**
  * **ValueError** – if the provided samples are not grouped
  * [**fiftyone.core.collections.SampleCollection**](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) – 

### fiftyone.core.validation.validate_non_grouped_collection(sample_collection)

Validates that the provided samples are a
[`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) that is *not* grouped.

* **Parameters:**
  **sample_collection** – a sample collection
* **Raises:**
  * **ValueError** – if the provided samples are a grouped
  * [**fiftyone.core.collections.SampleCollection**](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) – 

### fiftyone.core.validation.validate_collection_label_fields(sample_collection, field_names, allowed_label_types, same_type=False)

Validates that the [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection)
has fields with the specified [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types.

* **Parameters:**
  * **sample_collection** – a
    [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection)
  * **field_names** – a field name or iterable of field names
  * **allowed_label_types** – a [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) type or
    iterable of allowed [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types
  * **same_type** (*False*) – whether to enforce that all fields have same type.
    This condition is enforced separately for sample- and frame-level
    fields
* **Raises:**
  **ValueError if the required conditions are not met** – 

### fiftyone.core.validation.get_field(sample, field_name, allowed_types=None, allow_none=True)

Gets the given sample field and optionally validates its type and value.

* **Parameters:**
  * **sample** – a [`fiftyone.core.sample.Sample`](fiftyone.core.sample.md#fiftyone.core.sample.Sample)
  * **field_name** – the name of the field to get
  * **allowed_types** (*None*) – an optional iterable of
    [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types to enforce that the field
    value has
  * **allow_none** (*True*) – whether to allow the field to be None
* **Returns:**
  the field value
* **Raises:**
  * **ValueError if the field does not exist** **or** **does not meet the specified** – 
  * **criteria** – 

### fiftyone.core.validation.get_fields(sample, field_names, allowed_types=None, same_type=False, allow_none=True)

Gets the given sample fields and optionally validates their types and
values.

* **Parameters:**
  * **sample** – a [`fiftyone.core.sample.Sample`](fiftyone.core.sample.md#fiftyone.core.sample.Sample)
  * **field_names** – an iterable of field names to get
  * **allowed_types** (*None*) – an optional iterable of
    [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types to enforce that the
    field values have
  * **same_type** (*False*) – whether to enforce that all fields have same type
  * **allow_none** (*True*) – whether to allow the fields to be None
* **Returns:**
  a tuple of field values
* **Raises:**
  * **ValueError if a field does not exist** **or** **does not meet the specified** – 
  * **criteria** –
