EvaluatedFormElement

API / @publicodes/forms / EvaluatedFormElement

type EvaluatedFormElement<Name> = 
  | EvaluatedCheckbox<Name>
  | EvaluatedStringInput<Name>
  | EvaluatedNumberInput<Name>
  | EvaluatedRadioGroup<Name>
  | EvaluatedSelect<Name>
| EvaluatedTextarea<Name>;

Defined in: evaluatedFormElement.ts:92

Represents the different types of form elements that can be generated from Publicodes rules.

Each evaluated form element includes common properties:

  • applicable: Whether the field should be shown based on applicability rules
  • required: Whether user input is required for this field
  • answered: Whether the field has been answered/filled
  • value: The current value of the field (in the situation)
  • defaultValue: The default value of the field if not answered

Type Parameters

Type ParameterDefault type
Name extends stringstring

Example

// Example of an evaluated number input
const evaluatedField: EvaluatedFormElement = {
  element: 'input',
  type: 'number',
  id: 'salary',
  label: 'Monthly salary',
  applicable: true,
  required: true,
  answered: false,
  value: 3000,
  unit: '€',
  defaultValue: 2500
}

See