PreviewPolicy

fun PreviewPolicy(initialMode: PreviewValidationMode = PreviewValidationMode.Change): PreviewPolicy

Creates a preview policy with the specified initial validation mode.

This factory function creates a PreviewPolicy instance configured for use in Compose Previews and testing. The policy determines when field validation should be triggered during the preview lifecycle.

The validation strategy is simplified compared to production forms:

  • Initial validation occurs based on the specified mode

  • Subsequent validation always occurs on value changes

  • No complex form-wide validation dependencies

Usage:

// Validate immediately when the field is mounted (useful for testing error states)
val mountPolicy = PreviewPolicy(PreviewValidationMode.Mount)

// Validate only when the field value changes (default behavior)
val changePolicy = PreviewPolicy(PreviewValidationMode.Change)

Return

A configured PreviewPolicy instance.

Parameters

initialMode

The validation mode that determines when initial validation occurs.