# Conditional Logic Demo # Demonstrates all supported conditional operators in TypeDialog description = "Complete demonstration of conditional field visibility" name = "conditional_demo" # ==================== # COMPARISON OPERATORS # ==================== [[elements]] name = "database_driver" options = [ { value = "sqlite", label = "SQLite (embedded)" }, { value = "mysql", label = "MySQL" }, { value = "postgresql", label = "PostgreSQL" }, ] prompt = "Select database driver" required = true type = "select" # Equality (==) [[elements]] name = "mysql_config" placeholder = "mysql://localhost:3306/db" prompt = "MySQL connection string" type = "text" when = "database_driver == mysql" # Inequality (!=) [[elements]] content = "⚠️ You selected a server-based database. Ensure the server is running." name = "server_warning" type = "section" when = "database_driver != sqlite" # ==================== # NUMERIC COMPARISONS # ==================== [[elements]] default = "8080" name = "server_port" prompt = "Server port" required = true type = "text" # Greater than (>) [[elements]] content = "⚠️ Port > 10000 is uncommon. Double-check your configuration." name = "high_port_warning" type = "section" when = "server_port > 10000" # Less than (<) [[elements]] content = "⚠️ Port < 1024 requires root/admin privileges." name = "privileged_port_warning" type = "section" when = "server_port < 1024" # Greater than or equal (>=) [[elements]] content = "✓ Using standard user port range (>= 1024)" name = "standard_port_notice" type = "section" when = "server_port >= 1024" # Less than or equal (<=) [[elements]] content = "Using low port range (<= 5000)" name = "low_port_range" type = "section" when = "server_port <= 5000" # ==================== # STRING OPERATORS # ==================== [[elements]] name = "project_url" placeholder = "https://github.com/user/repo" prompt = "Project repository URL" type = "text" # startswith [[elements]] content = "✓ Secure HTTPS URL detected" name = "https_notice" type = "section" when = "project_url startswith https" # endswith [[elements]] name = "github_specific" prompt = "GitHub Actions enabled?" type = "text" when = "project_url endswith github.com" # contains [[elements]] name = "gitlab_ci" prompt = "Enable GitLab CI integration?" type = "confirm" when = "project_url contains gitlab" # ==================== # ARRAY MEMBERSHIP (in) # ==================== [[elements]] display_mode = "grid" name = "detected_languages" options = [ { value = "rust", label = "🦀 Rust" }, { value = "python", label = "🐍 Python" }, { value = "javascript", label = "📜 JavaScript" }, { value = "go", label = "🐹 Go" }, ] prompt = "Which languages are used in your project?" type = "multiselect" # Array membership check [[elements]] name = "rust_toolchain" options = [ { value = "stable", label = "Stable" }, { value = "nightly", label = "Nightly" }, { value = "beta", label = "Beta" }, ] prompt = "Rust toolchain version" type = "select" when = "rust in detected_languages" [[elements]] default = true name = "python_venv" prompt = "Use Python virtual environment?" type = "confirm" when = "python in detected_languages" [[elements]] name = "nodejs_version" options = [ { value = "18", label = "Node.js 18 LTS" }, { value = "20", label = "Node.js 20 LTS" }, { value = "latest", label = "Latest" }, ] prompt = "Node.js version" type = "select" when = "javascript in detected_languages" # ==================== # FILE SYSTEM CONDITIONS # ==================== # file_exists(path) [[elements]] content = "✓ Dockerfile found in current directory" name = "dockerfile_exists_notice" type = "section" when = "file_exists(Dockerfile)" # !file_exists(path) - negation [[elements]] default = true name = "create_dockerfile" prompt = "No Dockerfile found. Create one?" type = "confirm" when = "!file_exists(Dockerfile)" [[elements]] name = "use_existing_config" prompt = "Existing .env file found. Use existing configuration?" type = "confirm" when = "file_exists(.env)" [[elements]] includes = ["fragments/environment-setup.toml"] name = "env_setup" type = "group" when = "!file_exists(.env)" # ==================== # COMBINED CONDITIONS # ==================== [[elements]] content = "🦀 Rust + Docker detected. Consider using rust:alpine base image." name = "rust_docker_setup" type = "section" when = "rust in detected_languages" [[elements]] content = "✅ Production-ready configuration detected (HTTPS + standard port)" name = "production_ready_check" type = "section" when = "server_port >= 1024"