elsa-workflows / elsa-studio

A modular, extensible dashboard application framework
MIT License
187 stars 90 forks source link

Missing input validation in Elsa Workflow Editor for inherited CodeActivity<T> classes. #306

Open anupam-mangal opened 1 month ago

anupam-mangal commented 1 month ago

When I define a new activity like the example below, all fields rendered by the Elsa workflow editor are always of type string.

public class CustomActivity : CodeActivity<SampleDTO>
{
  [Input(Description = "Field description")]
  [Range(0, int.MaxValue)]
  public Input<int> Order { get; set; } = default!;

  [Input(Description = "Field description")]
  public Input<string> CustomString { get; set; } = default!;
}

When the above class is used in Elsa Wokflow editor, both the fields are displayed of type 'string'.

I believe Elsa Editor knows the data types of each field it is rendering but somehow it does not use that information to create numeric fields for numeric data types (input validation). Without this feature, users can enter any alphabetic or alphanumeric string for integer or other numeric fields while creating/editing a workflow definition. Further, I do not see any hook or annotation or any way to add custom input validation rules to custom activity fields.

Please consider fixing this issue for the benefit of Elsa users. I am using Elsa 3.2.0.