Repository navigation
Example BGP custom data validator not working #113
Description
Activity
Thanks for submitting this issue, @Glynn608.
We may have introduced a breaking change which impacted the CheckARIN example. I'm working through that now, but in that case, the validator fails completely. It sounds like you may be seeing something different.
Can you confirm which example you tried to use? Was it the CheckARIN example or your own code?
Initially it was my own code. It didn't fail it, just seemed to not do anything. No errors, no logs.
I moved onto the CheckARIN example as I assumed I was missing something but also had no luck with that either 🙂
Can you tag me in the PR with working example when you get round to it please.
I've updated the example from the blog and submitted PR #114. Give that a try and let me know if you have any issues.
I'll update the documentation and tests separately, but that PR will give you a starting point.
Also, the default behavior of schema-enforcer is to only output errors. You can use the
--show-passflag to see the files that pass.This was a great help I have it functioning now. My config wasn't finding the validators folder :(
Follow up question, is it intended that the validators folder lives in the
schema/main dir or the dir where the CLI command is executed? Currently the default is the dir where the command is executed.gwindebank@gwindeban35-mac [chipn/validator-example]example4 $ tree . ├── host_vars │ ├── az_rtr_01 │ │ └── peers.yml │ └── az_rtr_02 │ └── peers.yml ├── schema │ ├── definitions │ ├── schemas │ ├── tests │ └── validators └── validators ├── __pycache__ │ └── check_arin.cpython-39.pyc └── check_arin.pyIt might be nice to add an example .toml file and other folders to example 4 and update the defaults for validators in the docs https://github.com/networktocode/schema-enforcer/blob/main/docs/configuration.md#default-configuration-settings
The default is
validatorsin the current directory which is why the default doc doesn't include the language about being nested inmain_directory.You can configure it to be nested by adding this to your pyproject.toml file:[tool.schema_enforcer] validator_directory = "schema/validators"I'm open to switching the default to being nested in the main_directory along with the others though.
Environment
Expected Behavior
The schema should load and validate data against the
validatefunction with exits ofself.add_validation_error()andself.add_validation_pass()Observed Behavior
The schema appears to be registering but doesn't action anything in the script.
Steps to Reproduce
Side note, the example4 folder doesn't seems to exist like in the blog post, does anyone have a working example of custom validators using https://github.com/networktocode/schema-enforcer/blob/develop/docs/custom_validators.md#basevalidation?
Maybe I'm missing something in the .toml file? Any examples?