Continued work on updating documentation for plugins, added automatic constraint validation:
AttrSpec.Constraints - contains or'ed (|) together flags:
constraint.Required - makes the attr required, replaces the AttrSpec.Required bool
constraint.NonNull - forbids null values
constraint.NonEmpty - forbids empty collections or empty strings (sets AttrSpec.MinInclusive to at least 1)
constraint.TrimSpace - not really a constraint, but a pre-processing step (decided to keep it here, since NonEmpty doesn't really make sense on a whitespace string without trimming). If the value type is a string – it would be trimmed before being validated and passed to the plugin code. Non-string values are unaffected
constraint.Integer - requires cty.Number to be a whole integer
Some other common combinations of these constraints are also defined
AttrSpec.OneOf - If set then value must be one of the specified values
AttrSpec.MinInclusive - For numbers - min value; for collections - min number of elements; for strings - min length
AttrSpec.MaxInclusive - For numbers - max value; for collections - max number of elements; for strings - max length
AttrSpec.Deprecated - If specified – a deprecation warning would appear if an attribute is specified and non-null
Most of these constraints are also integrated with doc gen
See toc.md for the examples of the new property documentation
Continued work on updating documentation for plugins, added automatic constraint validation:
AttrSpec.Constraints
- contains or'ed (|
) together flags:constraint.Required
- makes the attr required, replaces theAttrSpec.Required
boolconstraint.NonNull
- forbids null valuesconstraint.NonEmpty
- forbids empty collections or empty strings (sets AttrSpec.MinInclusive to at least 1)constraint.TrimSpace
- not really a constraint, but a pre-processing step (decided to keep it here, sinceNonEmpty
doesn't really make sense on a whitespace string without trimming). If the value type is a string – it would be trimmed before being validated and passed to the plugin code. Non-string values are unaffectedconstraint.Integer
- requirescty.Number
to be a whole integerAttrSpec.OneOf
- If set then value must be one of the specified valuesAttrSpec.MinInclusive
- For numbers - min value; for collections - min number of elements; for strings - min lengthAttrSpec.MaxInclusive
- For numbers - max value; for collections - max number of elements; for strings - max lengthAttrSpec.Deprecated
- If specified – a deprecation warning would appear if an attribute is specified and non-nullMost of these constraints are also integrated with doc gen
See toc.md for the examples of the new property documentation