- On the top right of the page, click "Use this template", select "create a new repository" and set a name for the package. See Naming Conventions below.
- Clone down the new repository.
- Modify the class in validator/main.py with source code for the new validator
- Make sure that the class still inherits from
Validator
and has theregister_validator
annotation. - Set the
name
in theregister_validator
to the name of the repo prefixed with your org as a namespace and set the appropriate data type.
- Make sure that the class still inherits from
- Change validator/init.py to your new Validator classname instead of ValidatorTemplate
- Perform a self install with
make dev
orpip install -e ".[dev]"
- Locally test the validator with the test instructions below
- Modify the README and follow the Validator Card format; you can find an example here
- Note: This package uses a pyproject.toml file, on first run, run
make dev
to pull down and install all dependencies
- Avoid using
is
andbug
- Use snake_case: i.e.
_
to separate words. e.g. valid_address - For the description of the repo, write one sentence that says what the validator does; should be the same as the description in the pydoc string.
- When annotating the class use the
{namespace}/{validator_name}
pattern: e.g.@register_validator(name=“guardrails/valid_address”)
- Open test/test-validator.py to test your new validator
- Import your new validator and modify
ValidatorTestObject
accordingly - Modify the TEST_OUTPUT and TEST_FAIL_OUTPUT accordingly
- Run
python test/test-validator.py
via terminal, make sure the returned output reflects the input object - Write advanced tests for failures, etc.
- Update the pyproject.toml file and make necessary changes as follows:
- Update the
name
field to the name of your validator - Update the
description
field to a short description of your validator - Update the
authors
field to your name and email - Add/update the
dependencies
field to include all dependencies your validator needs.
- Update the
- If there are are any post-installation steps such as downloading tokenizers, logging into huggingface etc., update the post-install.py file accordingly.
- You can add additional files to the validator directory, but don't rename any existing files/directories.
- e.g. Add any environment variables (without the values, just the keys) to the .env file.
- Ensure that there are no other dependencies or any additional steps required to run your validator.