[Catalyst] transforming empty values in request to perl's undef

Rajesh Kumar Mallah mallah at redgrape.tech
Thu Mar 2 16:14:54 GMT 2017


By empty i mean string with length 0 ie ''

__CODE__


I am posting to rest endpoint Automagically generated via
Catalyst::Controller::DBIC::API  there is no explicit code hand
written by me.And that is why looking for a global filter.

There are three great virtues of a programmer; Laziness, Impatience and
Hubris -- Larry Wall.



> Just curious: when you say "prefilled with nothing", you mean the field is
> empty, or the field is filled with one or more white spaces (like " "), or
> the field is a <select> with the first <option> having the attribute
> "value" equals to ""? Or something else?
>
> gil
>
> On Thu, Mar 02, 2017 at 10:25:27AM -0500, Rajesh Kumar Mallah wrote:
>>
>> Hi ,
>>
>> I want to transform request parameters in GET & POST requests
>> so that any thing which is empty (string) gets converted/replaced
>> my perl's undef (and DBIC's NULL).
>>
>> Why i need that:
>> ====================
>> I have edit form in my web app and some fields in the edit form
>> are prefilled with nothing. On submission the DB raises an exception
>> that an empty string is being inserted to a integer field.
>>
>> Hence I feel like having a global filter that turns all blanks to
>> undef.
>>
>> The question is where to put this global filter.
>>
>> Regds
>> mallah.
>>
>>
>>
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive:
>> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>







More information about the Catalyst mailing list