<div dir="ltr"><div><div><div>So after more searching and reading of source, I think I have this working. It looks like the inflator has to die upon failure to trigger the error within the eval that inflates the input into an object. At least that seems to be working now. The final code for the module looks like this:<br><br>package HTML::FormFu::Inflator::NetAddr::IP;<br><br>use strict;<br>use warnings;<br><br>use Moose;<br>use NetAddr::IP;<br>use namespace::autoclean;<br><br>extends &#39;HTML::FormFu::Inflator&#39;;<br><br>sub inflator {<br>    my ( $self, $value ) = @_;<br><br>    return if !defined $value || $value eq &#39;&#39;;<br><br>    my $ip = NetAddr::IP-&gt;new($value);<br><br>    die if ref $ip ne &#39;NetAddr::IP&#39;;<br><br>    return $ip;<br>}<br> <br><br>__PACKAGE__-&gt;meta-&gt;make_immutable;<br><br>1;<br><br></div>As this seems to be working, I am moving on to the next steps with the project. If it seems to fail later, I will be back. In the meantime, I would still like confirmation that this is the correct way to implement an inflator.<br><br></div>Thanks,<br></div>Bill<br><br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 14, 2018 at 9:04 AM, Bill Uhl <span dir="ltr">&lt;<a href="mailto:bill@greenlightnet.com" target="_blank">bill@greenlightnet.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi,<br><br>I am trying to write an inflator that will produce a NetAddr::IP object from my form input. I have searched for but been unable to find much information about writing custom inflators. If there are examples or additional documentation available, links would be greatly appreciated.<br><br>I am working on my first Catalyst web site with DBIC and FormFu. I am using the built-in Catalyst server to display the web pages. The whole thing is running on a CentOS 7.5 VM on one of my servers.<br><br>I took a look at the source for the core inflators and from what I (mis)understand of the code, the inflator provides an inflator method that returns on failure or returns the inflated object upon success. I have written the following but it does not work as I expected.<br><br><span style="font-family:monospace,monospace">package HTML::FormFu::Inflator::<wbr>NetAddr::IP;<br>use Moose;<br>use HTML::FormFu::Constants qw( $EMPTY_STR );<br>use NetAddr::IP;<br>use namespace::autoclean;<br><br>extends &#39;HTML::FormFu::Inflator&#39;;<br><br>sub inflator {<br>    my ( $self, $value ) = @_;<br><br>    return if !defined $value || $value eq $EMPTY_STR;<br><br>    my $ip = NetAddr::IP-&gt;new($value);<br>    return if !defined $ip;<br><br>    return $ip;<br>}<br><br>__PACKAGE__-&gt;meta-&gt;make_<wbr>immutable;<br><br>1;</span><br><br></div>With the following form config...<br><br><span style="font-family:monospace,monospace">  # Text box for the network subnet address<br>  - type: Text<br>    name: subnet<br>    label: Subnet<br>    attributes:<br>      title: Enter the Subnet Address for this network in CIDR format.<br>    inflators:<br>      - type: NetAddr::IP<br>        message: Not a valid subnet address.<br></span><br></div>Even when I enter a valid address that should be inflatable, such as <a href="http://10.255.255.0/24" target="_blank">10.255.255.0/24</a>,  I get the &#39;Not a valid subnet address&#39; error message.<br><br></div>Any help or redirection would be appreciated.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Bill<br><br><div><div><br><br></div></div></font></span></div>
</blockquote></div><br></div>