.BaseValidatorModel

gd.validators.BaseValidatorModel

class glyphdeck.validators.BaseValidatorModel

Bases: BaseModel

Base class for validator models. Provides common field validations, which are used in columns match the arguments.

Multiple validations can apply to a single field if the column name is in multiple validation rules.

Parameters:

BaseModel – The base class for Pydantic models.

Returns:

An instance of the base validator model.

Return type:

BaseValidatorModel

classmethod check_decimal_places(
v: float | int,
) float | int

Check that the value has no more than two decimal places.

Parameters:

v – The value to be validated, either float or int.

Returns:

The validated value if it passes the check.

classmethod list_1_to_30(
v: List,
) List

Validate that the list contains between 1 to 30 entries.

Parameters:

v – The list to be validated.

Returns:

The validated list if it passes the check.

classmethod list_1_to_5(
v: List,
) List

Validate that the list contains between 1 to 5 entries.

Parameters:

v – The list to be validated.

Returns:

The validated list if it passes the check.

classmethod list_of_sentiment_floats_in_range(
v: List[float | int],
) List[float | int]

Validate a list of sentiment scores ensuring values are floats within the allowed range.

Parameters:

v – The list of values to be validated.

Returns:

The validated list of values.

model_fields: ClassVar[Dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

classmethod sentiment_float_in_range(
v: float | int,
) float | int

Ensure the sentiment score is within the allowed range.

Parameters:

v – The value to be validated, either float or int.

Returns:

The validated value if it is within the specified range.