Chalk home page
  1. Features
  2. Validation

Feature Values

Chalk can enforce requirements on your feature values. You can validate the values and length of many primitive types through the keyword arguments min, max, min_length, and max_length.

To prevent ‘invalid’ features from being written to the offline or online store, set strict=True. In this case an error will be thrown when an invalid feature is observed. The validations keyword argument can be used when there are multiple validations, only some of which are strict.

from chalk import Validation
from chalk.features import feature, features

class Office:
    size_sqft: int = feature(min=0, max=100_000_000)
    street: str = feature(validations=[
        Validation(min_length=1, max_length=256, strict=True),
        Validation(min_length=20, max_length=100)

Feature validation requirements

For some features, it is important to specify metadata such as owner and description. Chalk allows you to enforce metadata requirement easily. In addition, you can specify for each feature the severity at which to raise a missing metadata issue.

In chalk.yml, the validation > feature > metadata section specifies settings for metadata validation. In the following example, users will be blocked from deploying features (chalk apply) with an unspecified owner. They are allowed to deploy features with missing description and tags.

project: Predict Q2 Spending

      - name: owner
        missing: error
      - name: description
        missing: warning
      - name: tags
        missing: info

    runtimes: 'python310'
    requirements: requirements.txt