Prompt file imported from demisto/demisto-sdk (
.github/prompts/new-validator.prompt.md). Copyright stays with the author.
Add a new validate validator
Use the conventions documented in
.github/instructions/validators.instructions.md
and the canonical reference
PB100_is_no_rolename.py.
Inputs to gather (ask the user before generating code)
- Content type — Playbook (
PB), Integration (IN), Script (SC), README (RM), Image (IM), Graph relation (GR), Best-practice (BA), Backwards-compat (BC), … - Error code — next free
<PREFIX>NNNfor that prefix. List existing files underdemisto_sdk/commands/validate/validators/<PREFIX>_validators/to find the next free number. - One-sentence description of what the validator checks.
- Rationale — why this matters to a content author.
- Error message with
{placeholders}that name the offending field, item, etc. - Related field(s) — the YAML/JSON key(s) most relevant to the check.
- Auto-fix? If yes, gather the fix logic and confirm idempotency.
Steps to perform
- Create
demisto_sdk/commands/validate/validators/<PREFIX>_validators/<CODE>_<snake_name>.pymatching the template in the validators instructions file. - Add a unit test under
demisto_sdk/commands/validate/tests/<PREFIX>_validators_tests/<CODE>_<snake_name>_test.pycovering at least:- A passing case.
- A failing case.
- The
fix()round-trip ifis_auto_fixable=True. UseTestSuite/builders to construct fixtures.
- Register the validator in
default_config.toml(andsdk_validation_config.tomlif it should run when validating this SDK repo). - Run:
poetry run pre-commit run validate-validation-config-file --all-files poetry run pytest demisto_sdk/commands/validate/tests -k <CODE> -x poetry run python demisto_sdk/commands/validate/generate_validate_docs.py - Add a
feature(orfix) changelog entry:poetry run sdk-changelog --init -n <PR-number>
Hard guardrails
- The validator must not make network calls, write to disk, or run git/docker commands.
- The error code must be globally unique and match the filename prefix.
- The validator must type-narrow on
ContentTypes; for multi-type validators use aUnion[...]. - Pydantic v1 only. Use the project logger and JSON/YAML handlers if you
need them (see
copilot-instructions.md).