Skip to content

feat: add custom validation extension#108

Open
khalsz wants to merge 1 commit into
iterorganization:mainfrom
khalsz:feature/validation-extension
Open

feat: add custom validation extension#108
khalsz wants to merge 1 commit into
iterorganization:mainfrom
khalsz:feature/validation-extension

Conversation

@khalsz

@khalsz khalsz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces support for loading an extended custom validator class from the server configuration. This allows users to extend SimDB's validation framework while remaining compatible with upstream releases, without needing to modify SimDB directly.

With this feature, users can install their own validation package into the application's virtual environment and specify the validator class to use in the server configuration.

Example configuration:

validation:
  custom_validator: myvalidator.validators.MyValidator

How it works

At startup, SimDB will:

  1. Read the configured validator class path.
  2. Dynamically import the specified module.
  3. Load the configured validator class.
  4. Verify that it inherits from CustomValidator.
  5. Use the configured validator class throughout the validation pipeline instead of the default CustomValidator.

If no custom validator is configured, SimDB continues to use the built-in CustomValidator, preserving the existing behaviour.

Benefits

  • Enables project-specific validation rules without modifying SimDB.
  • Makes the validation framework extensible while remaining compatible with upstream releases.
  • Maintains backward compatibility when no custom validator is configured.
  • Provides a clean extension point for custom validation implementations.

Example use case

A project can create its own package containing a validator implementation:

from simdb.validation.validator import CustomValidator

class MyValidator(CustomValidator):
    ...

After installing the package into the same virtual environment as SimDB, the project only needs to configure:

[validation]:
  custom_validator: myvalidator.validators.MyValidator

No changes to the SimDB source code are required.

import click
from pathlib import Path
from typing import Optional, List, Tuple, Any, Type
from typing import Any, List, Optional, Tuple, Type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep old code without formatting as this will be a patch? And we could better understand the real changes related to addition of custom validator.

from ...config.config import Config
from ...query import QueryType, parse_query_arg
from . import check_meta_args, pass_config
from .validators import validate_non_negative

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not get motivation of adding custom validation. Could you please share use case where you think ITER scenarios validation is more aggressive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support configurable custom validator extensions

2 participants