validation

2 min read

Declarative validation rules evaluated at admission time (via webhook) and at reconcile time. Declared on a CRDEntry or inside a Motif’s admission block.

validation:
  rules:
    - field: spec.replicas
      operator: lte
      value: "10"
      valueType: int
      message: "replicas must not exceed 10"

    - field: spec.engine
      equals: postgres
      message: "only postgres engine is supported"
      action: deny

    - field: spec.image
      prefix: "myregistry.example.com/"
      message: "image must come from the internal registry"
      action: warn

validation.rules

Each rule describes one check. Rules are evaluated in order.

FieldRequiredDescription
fieldyesDot-notation path in the CR (e.g. spec.replicas, spec.config.engine)
messageyesError or warning message — shown in events, webhook response, and logs
actionnodeny (default) — reject; warn — allow but log a warning
operator + valueyes*Explicit comparison (see operators)
valueTypenostring (default), int, float, bool

*Use either an operator+value pair or a shorthand field.

Operators

ShorthandOperatorDescription
equalseqField equals value
notEqualsneqField does not equal value
prefixprefixField starts with value
suffixsuffixField ends with value
containscontainsField contains substring
mingteField is greater than or equal (numeric)
maxlteField is less than or equal (numeric)
greaterThangtField is greater than (numeric)
lessThanltField is less than (numeric)

action

ValueEffect
deny (default)Webhook returns a rejection; reconcile fails with an error.
warnWebhook allows the operation; a warning is logged.

When validation runs

  • At admission: if security.webhooks.admission.enabled: true and the CRD’s webhooks.validation: true.
  • At reconcile: always — even without a webhook, rules are checked during each cycle.

→ Next: mutation.md