Skip to main content

confval v0.12.0

The non_empty and unique flags take a help line. #[confval(format = ...)] now applies to a PathBuf field. check_references alone decides whether a block label names anything. A handwritten spec builds its range and length records from the constants it checks with.

Highlights

  • #[confval(non_empty(help = "..."))] and #[confval(unique(help = "..."))] keep a help line in the diagnostic, the schema, and the hover.
  • #[confval(format = AbsolutePath)] compiles on a Located<PathBuf>.
  • #[confval(non_empty)] on a #[confval(label)] field is a compile error, because check_references reports an empty label.

Added

  • #[confval(non_empty(help = "..."))] and #[confval(unique(help = "..."))]. The help replaces the generated suggestion in the diagnostic. The schema keeps it in SchemaField::non_empty_help and SchemaField::unique_help. The hover reads it after the rule sentence.
  • NonEmptyConstraint::with_help and UniqueConstraint::with_help, for a handwritten spec that declares the rule once as a const.
  • SchemaField::with_non_empty_help and SchemaField::with_unique_help, which set the flag and keep the help line.
  • #[confval(format = ...)] on a Located<PathBuf> or an Option<Located<PathBuf>>. The check reads the path's text, and the schema records the format on the Path leaf.
  • check_format_path, in the prelude beside check_format. The derive emits it for a PathBuf leaf, and a handwritten Validate body calls it the same way.
  • RangeConstraint::constraint and LengthConstraint::constraint, which return the schema record for the constant a handwritten validate checks with. The derive emits the same call. A derived record and a handwritten record then come from one code path.

Changed

  • The compile error for a format on the wrong shape now reads #[confval(format = ...)] requires a String leaf, a Path leaf, or a string list.
  • NonEmptyConstraint and UniqueConstraint are structs with a help field and are #[non_exhaustive]. Write NON_EMPTY, UNIQUE, or with_help(...) where code named the bare type as a value.
  • check_references treats a whitespace-only label as empty. The empty label report has a help line that names the block and its label field. A reference to such a label no longer resolves.
  • The language server refuses to rename a whitespace-only label, the way it refuses an empty one.

Removed

  • The #[confval(label, non_empty)] pair. The derive rejects it with #[confval(non_empty)] cannot be combined with #[confval(label)]; check_references reports an empty label, so run that pass beside validate_all.

Upgrading

If a #[confval(label)] field has #[confval(non_empty)], delete the flag. Confirm that your pipeline runs check_references beside validate_all. That pass reports the empty label the flag used to report. A whitespace-only label now reports as empty. A reference to that label reports as undefined.

NonEmptyConstraint and UniqueConstraint are no longer unit structs, and both are #[non_exhaustive]. Where code wrote the bare type name as a value, write NON_EMPTY, UNIQUE, or NonEmptyConstraint::with_help(...). Where code matched the bare type name as a pattern, bind the value or match with NonEmptyConstraint { .. }. A struct literal of either type no longer compiles outside the crate.

[dependencies]
confval = { version = "0.12", features = ["derive", "hcl", "color"] }