Skip to content

Refactor validators to use Field() instead of @field_validator for simple gt/lt constraints #1342

@coderabbitai

Description

@coderabbitai

Description

As suggested in #1338, we should refactor validators that only check simple constraints (like ) to use Pydantic's declaration instead of decorators for consistency and cleaner code.

Background

During the Pydantic v2 upgrade in #1338, the class was updated to use with constraints:

archive: int = Field(default=60, gt=0)
search_result: int = Field(default=30, gt=0)

However, other classes like and still use decorators for similar simple validations.

Proposed Changes

Refactor the following fields to use with appropriate constraints:

ArchiveOutput class

  • target_archive_size: int = Field(default=256 * 1024 * 1024, gt=0)
  • target_dictionaries_size: int = Field(default=32 * 1024 * 1024, gt=0)
  • target_encoded_file_size: int = Field(default=256 * 1024 * 1024, gt=0)
  • target_segment_size: int = Field(default=256 * 1024 * 1024, gt=0)
  • compression_level: int = Field(default=3, ge=1, le=19)
  • retention_period: Optional[int] = Field(default=None, gt=0)

StreamOutput class

  • target_uncompressed_size: int = Field(default=128 * 1024 * 1024, gt=0)

This would make the code more consistent and reduce boilerplate validator methods.

References

Files to modify

  • components/clp-py-utils/clp_py_utils/clp_config.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions