✓ Verified 📱 Social Media ✓ Enhanced Data

Fosmvvm Fields Generator

Generate FOSMVVM Fields protocols with validation rules, FormField definitions, and localized messag

Rating
4.1 (253 reviews)
Downloads
25,719 downloads
Version
1.0.0

Overview

Generate FOSMVVM Fields protocols with validation rules, FormField definitions, and localized messages.

Complete Documentation

View Source →

FOSMVVM Fields Generator

Generate Form Specifications following FOSMVVM patterns.

Conceptual Foundation

For full architecture context, see FOSMVVMArchitecture.md | OpenClaw reference

A Form Specification (implemented as a {Name}Fields protocol) is the single source of truth for user input. It answers:

  • What data can the user provide? (properties)
  • How should it be presented? (FormField with type, keyboard, autofill semantics)
  • What constraints apply? (validation rules)
  • What messages should be shown? (localized titles, placeholders, errors)

Why This Matters

The Form Specification is defined once, used everywhere:

swift
// Same protocol adopted by different consumers:
struct CreateIdeaRequestBody: ServerRequestBody, IdeaFields { ... }  // HTTP transmission
@ViewModel struct IdeaFormViewModel: IdeaFields { ... }              // Form rendering
final class Idea: Model, IdeaFields { ... }                          // Persistence validation

This ensures:

  • Consistent validation - Same rules on client and server
  • Shared localization - One YAML file, used everywhere
  • Single source of truth - Change once, applies everywhere

Connection to FOSMVVM

Form Specifications integrate with:

  • Localization System - FormField titles/placeholders and validation messages use LocalizableString
  • Validation System - Implements ValidatableModel protocol
  • Request System - RequestBody types adopt Fields for validated transmission
  • ViewModel System - ViewModels adopt Fields for form rendering

When to Use This Skill

  • Defining a new form (create, edit, filter, search)
  • Adding validation to a request body
  • Any type that needs to conform to ValidatableModel
  • When fosmvvm-fluent-datamodel-generator needs form fields for a DataModel

What This Skill Generates

A complete Form Specification consists of 3 files:

FilePurpose
{Name}Fields.swiftProtocol + FormField definitions + validation methods
{Name}FieldsMessages.swift@FieldValidationModel struct with @LocalizedString properties
{Name}FieldsMessages.ymlYAML localization (titles, placeholders, error messages)

Project Structure Configuration

Replace placeholders with your project's actual paths:

PlaceholderDescriptionExample
{ViewModelsTarget}Shared ViewModels SPM targetViewModels, SharedViewModels
{ResourcesPath}Localization resources pathSources/Resources
Expected Structure:
text
Sources/
  {ViewModelsTarget}/
    FieldModels/
      {Name}Fields.swift
      {Name}FieldsMessages.swift
  {ResourcesPath}/
    FieldModels/
      {Name}FieldsMessages.yml

How to Use This Skill

Invocation: /fosmvvm-fields-generator

Prerequisites:

  • Form purpose understood from conversation context
  • Field requirements discussed (names, types, constraints)
  • Entity relationship identified (what is this form creating/editing)
Workflow integration: This skill is used when defining form validation and user input contracts. The skill references conversation context automatically—no file paths or Q&A needed. Often precedes fosmvvm-fluent-datamodel-generator for form-backed models.

Pattern Implementation

This skill references conversation context to determine Fields protocol structure:

Form Analysis

From conversation context, the skill identifies:

  • Form purpose (create, edit, filter, login, settings)
  • Entity relation (User, Idea, Document - what's being created/edited)
  • Protocol naming (CreateIdeaFields, UpdateProfile, LoginCredentials)

Field Design

For each field from requirements:

  • Property specification (name, type, optional vs required)
  • Presentation type (FormFieldType: text, textArea, select, checkbox)
  • Input semantics (FormInputType: email, password, tel, date)
  • Constraints (required, length range, value range, date range)
  • Localization (title, placeholder, validation error messages)

File Generation Order

  • Fields protocol with FormField definitions and validation
  • FieldsMessages struct with @LocalizedString properties
  • FieldsMessages YAML with localized strings

Context Sources

Skill references information from:

  • Prior conversation: Form requirements, field specifications discussed
  • Specification files: If Claude has read form specs into context
  • Existing patterns: From codebase analysis of similar Fields protocols

Key Patterns

Protocol Structure

swift
public protocol {Name}Fields: ValidatableModel, Codable, Sendable {
    var fieldName: FieldType { get set }
    var {name}ValidationMessages: {Name}FieldsMessages { get }
}

FormField Definition

swift
static var contentField: FormField<String?> { .init(
    fieldId: .init(id: "content"),
    title: .localized(for: {Name}FieldsMessages.self, propertyName: "content", messageKey: "title"),
    placeholder: .localized(for: {Name}FieldsMessages.self, propertyName: "content", messageKey: "placeholder"),
    type: .textArea(inputType: .text),
    options: [
        .required(value: true)
    ] + FormInputOption.rangeLength(contentRange)
) }

FormField Types Reference

FormFieldTypeUse Case
.text(inputType:)Single-line input
.textArea(inputType:)Multi-line input
.checkboxBoolean toggle
.selectDropdown selection
.colorPickerColor selection

FormInputType Reference (common ones)

FormInputTypeKeyboard/Autofill
.textDefault keyboard
.emailAddressEmail keyboard, email autofill
.passwordSecure entry
.telPhone keyboard
.urlURL keyboard
.date, .datetimeLocalDate picker
.givenName, .familyNameName autofill

Validation Method Pattern

swift
internal func validateContent(_ fields: [FormFieldBase]?) -> [ValidationResult]? {
    guard fields == nil || (fields?.contains(Self.contentField) == true) else {
        return nil
    }

    var result = [ValidationResult]()

    if content.isEmpty {
        result.append(.init(
            status: .error,
            field: Self.contentField,
            message: {name}ValidationMessages.contentRequiredMessage
        ))
    } else if !Self.contentRange.contains(NSString(string: content).length) {
        result.append(.init(
            status: .error,
            field: Self.contentField,
            message: {name}ValidationMessages.contentOutOfRangeMessage
        ))
    }

    return result.isEmpty ? nil : result
}

Messages Struct Pattern

swift
@FieldValidationModel public struct {Name}FieldsMessages {
    @LocalizedString("content", messageGroup: "validationMessages", messageKey: "required")
    public var contentRequiredMessage

    @LocalizedString("content", messageGroup: "validationMessages", messageKey: "outOfRange")
    public var contentOutOfRangeMessage
}

YAML Structure

yaml
en:
  {Name}FieldsMessages:
    content:
      title: "Content"
      placeholder: "Enter your content..."
      validationMessages:
        required: "Content is required"
        outOfRange: "Content must be between 1 and 10,000 characters"

Naming Conventions

ConceptConventionExample
Protocol{Name}FieldsIdeaFields, CreateIdeaFields
Messages struct{Name}FieldsMessagesIdeaFieldsMessages
Messages property{name}ValidationMessagesideaValidationMessages
Field definition{fieldName}FieldcontentField
Range constant{fieldName}RangecontentRange
Validate methodvalidate{FieldName}validateContent
Required message{fieldName}RequiredMessagecontentRequiredMessage
OutOfRange message{fieldName}OutOfRangeMessagecontentOutOfRangeMessage

See Also

Version History

VersionDateChanges
1.02024-12-24Initial skill
2.02024-12-26Rewritten with conceptual foundation; generalized from Kairos-specific
2.12026-01-24Update to context-aware approach (remove file-parsing/Q&A). Skill references conversation context instead of asking questions or accepting file paths.

Installation

Terminal bash

openclaw install fosmvvm-fields-generator
    
Copied!

💻Code Examples

final class Idea: Model, IdeaFields { ... } // Persistence validation

final-class-idea-model-ideafields-----persistence-validation.txt
This ensures:
- **Consistent validation** - Same rules on client and server
- **Shared localization** - One YAML file, used everywhere
- **Single source of truth** - Change once, applies everywhere

### Connection to FOSMVVM

Form Specifications integrate with:
- **Localization System** - FormField titles/placeholders and validation messages use `LocalizableString`
- **Validation System** - Implements `ValidatableModel` protocol
- **Request System** - RequestBody types adopt Fields for validated transmission
- **ViewModel System** - ViewModels adopt Fields for form rendering

## When to Use This Skill

- Defining a new form (create, edit, filter, search)
- Adding validation to a request body
- Any type that needs to conform to `ValidatableModel`
- When `fosmvvm-fluent-datamodel-generator` needs form fields for a DataModel

## What This Skill Generates

A complete Form Specification consists of **3 files**:

| File | Purpose |
|------|---------|
| `{Name}Fields.swift` | Protocol + FormField definitions + validation methods |
| `{Name}FieldsMessages.swift` | `@FieldValidationModel` struct with `@LocalizedString` properties |
| `{Name}FieldsMessages.yml` | YAML localization (titles, placeholders, error messages) |

## Project Structure Configuration

Replace placeholders with your project's actual paths:

| Placeholder | Description | Example |
|-------------|-------------|---------|
| `{ViewModelsTarget}` | Shared ViewModels SPM target | `ViewModels`, `SharedViewModels` |
| `{ResourcesPath}` | Localization resources path | `Sources/Resources` |

**Expected Structure:**

{Name}FieldsMessages.yml

-namefieldsmessagesyml.txt
## How to Use This Skill

**Invocation:**
/fosmvvm-fields-generator

**Prerequisites:**
- Form purpose understood from conversation context
- Field requirements discussed (names, types, constraints)
- Entity relationship identified (what is this form creating/editing)

**Workflow integration:**
This skill is used when defining form validation and user input contracts. The skill references conversation context automatically—no file paths or Q&A needed. Often precedes fosmvvm-fluent-datamodel-generator for form-backed models.

## Pattern Implementation

This skill references conversation context to determine Fields protocol structure:

### Form Analysis

From conversation context, the skill identifies:
- **Form purpose** (create, edit, filter, login, settings)
- **Entity relation** (User, Idea, Document - what's being created/edited)
- **Protocol naming** (CreateIdeaFields, UpdateProfile, LoginCredentials)

### Field Design

For each field from requirements:
- **Property specification** (name, type, optional vs required)
- **Presentation type** (FormFieldType: text, textArea, select, checkbox)
- **Input semantics** (FormInputType: email, password, tel, date)
- **Constraints** (required, length range, value range, date range)
- **Localization** (title, placeholder, validation error messages)

### File Generation Order

1. Fields protocol with FormField definitions and validation
2. FieldsMessages struct with @LocalizedString properties
3. FieldsMessages YAML with localized strings

### Context Sources

Skill references information from:
- **Prior conversation**: Form requirements, field specifications discussed
- **Specification files**: If Claude has read form specs into context
- **Existing patterns**: From codebase analysis of similar Fields protocols

## Key Patterns

### Protocol Structure

) }

-.txt
### FormField Types Reference

| FormFieldType | Use Case |
|---------------|----------|
| `.text(inputType:)` | Single-line input |
| `.textArea(inputType:)` | Multi-line input |
| `.checkbox` | Boolean toggle |
| `.select` | Dropdown selection |
| `.colorPicker` | Color selection |

### FormInputType Reference (common ones)

| FormInputType | Keyboard/Autofill |
|---------------|-------------------|
| `.text` | Default keyboard |
| `.emailAddress` | Email keyboard, email autofill |
| `.password` | Secure entry |
| `.tel` | Phone keyboard |
| `.url` | URL keyboard |
| `.date`, `.datetimeLocal` | Date picker |
| `.givenName`, `.familyName` | Name autofill |

### Validation Method Pattern
example.txt
// Same protocol adopted by different consumers:
struct CreateIdeaRequestBody: ServerRequestBody, IdeaFields { ... }  // HTTP transmission
@ViewModel struct IdeaFormViewModel: IdeaFields { ... }              // Form rendering
final class Idea: Model, IdeaFields { ... }                          // Persistence validation
example.txt
Sources/
  {ViewModelsTarget}/
    FieldModels/
      {Name}Fields.swift
      {Name}FieldsMessages.swift
  {ResourcesPath}/
    FieldModels/
      {Name}FieldsMessages.yml
example.txt
public protocol {Name}Fields: ValidatableModel, Codable, Sendable {
    var fieldName: FieldType { get set }
    var {name}ValidationMessages: {Name}FieldsMessages { get }
}
example.txt
static var contentField: FormField<String?> { .init(
    fieldId: .init(id: "content"),
    title: .localized(for: {Name}FieldsMessages.self, propertyName: "content", messageKey: "title"),
    placeholder: .localized(for: {Name}FieldsMessages.self, propertyName: "content", messageKey: "placeholder"),
    type: .textArea(inputType: .text),
    options: [
        .required(value: true)
    ] + FormInputOption.rangeLength(contentRange)
) }
example.txt
internal func validateContent(_ fields: [FormFieldBase]?) -> [ValidationResult]? {
    guard fields == nil || (fields?.contains(Self.contentField) == true) else {
        return nil
    }

    var result = [ValidationResult]()

    if content.isEmpty {
        result.append(.init(
            status: .error,
            field: Self.contentField,
            message: {name}ValidationMessages.contentRequiredMessage
        ))
    } else if !Self.contentRange.contains(NSString(string: content).length) {
        result.append(.init(
            status: .error,
            field: Self.contentField,
            message: {name}ValidationMessages.contentOutOfRangeMessage
        ))
    }

    return result.isEmpty ? nil : result
}
example.txt
@FieldValidationModel public struct {Name}FieldsMessages {
    @LocalizedString("content", messageGroup: "validationMessages", messageKey: "required")
    public var contentRequiredMessage

    @LocalizedString("content", messageGroup: "validationMessages", messageKey: "outOfRange")
    public var contentOutOfRangeMessage
}
example.yml
en:
  {Name}FieldsMessages:
    content:
      title: "Content"
      placeholder: "Enter your content..."
      validationMessages:
        required: "Content is required"
        outOfRange: "Content must be between 1 and 10,000 characters"

Tags

#communication

Quick Info

Category Social Media
Model Claude 3.5
Complexity One-Click
Author foscomputerservices
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install fosmvvm-fields-generator