feedzai-openml icon indicating copy to clipboard operation
feedzai-openml copied to clipboard

Field type to validate "free" text inputs

Open AndreFCruz opened this issue 3 years ago • 2 comments

I'm using the FreeTextFieldType class for an input that takes the following form:

  • <input_name>=<sequence-of-numbers>
  • e.g., arg1=1,0.3,9.8,2

I'm using the free text field as this is the only current suitable option, but I think it would be useful to add an optional parameter to the class constructor with a regex validator string, so we can check whether the input is valid before spinning-up a new model train process.

I think this minor modification to FreeTextFieldType could be useful to more people; and in my use case I'd just implement the input above as: new FreeTextFieldType("", "^((\d+(\.\d*)?,)*(\d+(\.\d*)?))?$") (1st parameter is the default value)

Shall I implement this and send in a PR?

PS: another option would be creating an entirely new FieldType CSVNumericFieldType that would be more specific to my case and would require larger code changes, but would also work.

AndreFCruz avatar May 23 '22 13:05 AndreFCruz

It's an okay from me. Please remember to not introduce breaking change (e.g., overload the constructor instead of changing its signature)

ghost avatar May 24 '22 07:05 ghost

I think that makes sense, the current validate method is doing nothing anyways :thinking:

Make sure that if no validation is provided the result is still a Optional.empty() to preserve current behavior.

If you need any help, let me know!

antssilva96 avatar May 24 '22 08:05 antssilva96