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.

Comment thread src/simdb/cli/commands/simulation.py
@olivhoenen

olivhoenen commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Hi @khalsz and @jholloc, as discussed at the developers meeting last week, please add this feature to develop in a new PR, and make the CLI client properly handle the case where this will be added directly to develop in the new PR. Then, please close this PR if you decide that you don't need an official tag 0.16 on main.

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

3 participants