Skip to content

Conversation

@jfet97
Copy link
Collaborator

@jfet97 jfet97 commented Dec 4, 2025

What

Added proper type detection and validation handling for S.Int schema fields to support German localized error messages. When users enter decimal values (e.g., 59.5) in integer fields, they now see the German translation ("Es wird eine ganze Zahl erwartet, tatsächlich: 59.5") instead of the English default.

Why

S.Int fields were losing their type information during metadata creation, causing them to be treated as regular numbers. This prevented:

  • Proper type distinction between integer and number fields
  • Correct German translation application for integer-specific validation errors
  • Appropriate error messages for decimal values in integer fields

The fix ensures consistent validation error messaging across different field types and respects the application's language configuration.

How

OmegaFormStuff.ts - createMeta function:

  • Added early detection of TitleAnnotation ("Int" or "int") BEFORE unwrapping Transformations
  • Prevents loss of Int type information that would otherwise occur from unwrapping
  • Sets type: "int" in metadata to distinguish from regular numbers

OmegaFormStuff.ts - generateInputStandardSchemaFromFieldMeta function:

  • Added new case "int" handler for integer field validation
  • Uses nested structure: S.Number.annotations({...}).pipe(S.int({...}))
  • S.Number provides German "empty field" message for undefined values
  • S.int provides German "integer expected" message with actual value for decimal inputs
  • Supports min/max constraints with appropriate German translations

OmegaInputVuetify.vue:

  • Added inputProps.type === 'int' to v-if condition for number inputs
  • Maps "int" type to "number" for HTML input element

tests/IntegerValidation.test.ts (new):

  • Tests German translations for integer validation
  • Validates correct behavior for decimal values, undefined values, and valid integers
  • Ensures type detection works properly for S.Int fields

stories/OmegaForm/IntegerValidationGerman.vue:

  • Fixed form submission handler to correctly access destructured value property

Files Changed

  • packages/vue-components/src/components/OmegaForm/OmegaFormStuff.ts
  • packages/vue-components/src/components/OmegaForm/OmegaInputVuetify.vue
  • packages/vue-components/__tests__/IntegerValidation.test.ts (new)
  • packages/vue-components/stories/OmegaForm/IntegerValidationGerman.vue

@jfet97 jfet97 merged commit c3cd0a2 into main Dec 4, 2025
3 checks passed
@jfet97 jfet97 deleted the thefixhopefully branch December 4, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants