---
name: step-05-validate
description: Validate build and SmartStack conventions
next_step: null
---

# Step 5: Validate

## YOUR TASK:

Verify the generated code compiles and follows SmartStack conventions.

---

## EXECUTION SEQUENCE:

### 1. Build Check

**Run build to verify compilation:**

```bash
dotnet build src/SmartStack.Api/SmartStack.Api.csproj --no-restore
```

**If build fails:**
- Parse error messages
- Fix issues in generated files
- Re-run build until success

### 2. Convention Validation

**Use SmartStack MCP to validate:**

```
mcp__smartstack__validate_conventions:
  checks: ["controllers", "services", "namespaces"]
```

**Manual checks:**

| Convention | Check | Status |
|------------|-------|--------|
| NavRoute attribute | `[NavRoute("{app}.{module}")]` present (NOT `[Route]`) | ✅/❌ |
| Authorize attribute | `[Microsoft.AspNetCore.Authorization.Authorize]` (fully qualified) | ✅/❌ |
| RequirePermission | Uses `Permissions.*` constants | ✅/❌ |
| ProducesResponseType | All endpoints documented | ✅/❌ |
| Logging | All CRUD operations logged | ✅/❌ |
| System account protection | Guard present (if applicable) | ✅/❌ |

### 3. Security Audit

**Verify security requirements:**

| Security Check | Required | Present |
|----------------|----------|---------|
| No string permission literals | Yes | ✅/❌ |
| No raw SQL | Yes | ✅/❌ |
| Input validation | Yes | ✅/❌ |
| Tenant isolation (if TenantEntity) | Yes | ✅/❌ |
| Audit logging | Yes | ✅/❌ |

### 4. Final Summary

**Display completion report:**

```
╔═══════════════════════════════════════════════════════════════════╗
║                    CONTROLLER GENERATED                            ║
╠═══════════════════════════════════════════════════════════════════╣
║  Controller: {area}/{module}Controller                             ║
║  Entity:     {entity}                                              ║
║  Type:       {controller_type}                                     ║
╠═══════════════════════════════════════════════════════════════════╣
║  FILES CREATED:                                                    ║
║  ✅ src/.../Controllers/{area}/{module}Controller.cs               ║
║  ✅ src/.../Authorization/Permissions.cs (updated)                 ║
║  ✅ src/.../Configurations/PermissionConfiguration.cs (updated)    ║
║  {dto_mode ? "✅ src/.../DTOs/{module}/*.cs" : ""}                 ║
║  {postman_mode ? "✅ tests/SmartStack.Security.postman.json" : ""} ║
╠═══════════════════════════════════════════════════════════════════╣
║  PERMISSIONS ADDED:                                                ║
║  🔐 {permission_path}.read                                         ║
║  🔐 {permission_path}.create                                       ║
║  🔐 {permission_path}.update                                       ║
║  🔐 {permission_path}.delete                                       ║
╠═══════════════════════════════════════════════════════════════════╣
║  NEXT STEPS:                                                       ║
║  1. Create migration: /efcore migration Add{module}Permissions     ║
║  2. Apply migration: /efcore db-deploy                             ║
║  3. Test endpoints in Swagger: /api/{area}/{module}                ║
║  4. Run Postman tests (if generated)                               ║
╚═══════════════════════════════════════════════════════════════════╝
```

---

## SUCCESS CRITERIA:

- Build passes without errors
- All conventions validated
- Security requirements met
- Clear summary displayed
- Next steps documented

## COMPLETION:

Controller generation complete. No more steps.
