def validate(path):  # pragma: no cover
    """
    Validates Dynaconf settings based on provided rules.

    Rules should be defined in dynaconf_validators.toml
    """
    # reads the 'dynaconf_validators.toml' from path
    # for each section register the validator for specific env
    # call validate
    path = Path(path)

    if not str(path).endswith(".toml"):
        path = path / "dynaconf_validators.toml"

    if not path.exists():  # pragma: no cover  # noqa
        click.echo(click.style(f"{path} not found", fg="white", bg="red"))
        sys.exit(1)

    # parse validator file
    try:  # try tomlib first
        validation_data = tomllib.load(open(str(path), "rb"))
    except UnicodeDecodeError:  # fallback to legacy toml (TBR in 4.0.0)
        warnings.warn(
            "TOML files should have only UTF-8 encoded characters. "
            "starting on 4.0.0 dynaconf will stop allowing invalid chars.",
        )
        validation_data = toml.load(
            open(str(path), encoding=default_settings.ENCODING_FOR_DYNACONF),
        )
    except tomllib.TOMLDecodeError as e:
        click.echo(
            click.style(
                f"Error parsing TOML: {e}. Maybe it should be quoted.",
                fg="white",
                bg="red",
            )
        )
        sys.exit(1)

    # guarantee there is an environment
    validation_data = {k.lower(): v for k, v in validation_data.items()}
    if not validation_data.get("default"):
        validation_data = {"default": validation_data}

    success = True
    for env, name_data in validation_data.items():
        for name, data in name_data.items():
            if not isinstance(data, dict):  # pragma: no cover
                click.echo(
                    click.style(
                        f"Invalid rule for parameter '{name}'"
                        "(this will be skipped)",
                        fg="white",
                        bg="yellow",
                    )
                )
            else:
                data.setdefault("env", env)
                click.echo(
                    click.style(
                        f"Validating '{name}' with '{data}'",
                        fg="white",
                        bg="blue",
                    )
                )
                try:
                    Validator(name, **data).validate(settings)
                except ValidationError as e:
                    click.echo(
                        click.style(f"Error: {e}", fg="white", bg="red")
                    )
                    success = False

    if success:
        click.echo(click.style("Validation success!", fg="white", bg="green"))
    else:
        click.echo(click.style("Validation error!", fg="white", bg="red"))
        sys.exit(1)

    Validates Dynaconf settings based on provided rules.

    Rules should be defined in dynaconf_validators.toml
    
dynaconf/cli.py