Hi,<br><br>I find for a number of models that I am using in my current project, I am creating actions for adding records so that I can validate that certain fields are not duplicated in the database rather than just using the Create<Name>.pm automatic action. I think that I could do this my having a validation function specified in the record definition within my model file, but is there a reason that we don't just use the 'is distinct' attribute to get the
<a href="http://Action.pm">Action.pm</a> default validator to do the checking always?<br><br>I hacked this into my local copy and it seemed to work fine:<br><br>Index: lib/Jifty/Action/Record.pm<br>===================================================================
<br>--- lib/Jifty/Action/Record.pm (revision 1124)<br>+++ lib/Jifty/Action/Record.pm (working copy)<br>@@ -227,7 +227,7 @@<br> }<br> <br> # If we're hand-coding a render_as, hints or label, let's use it.<br>
- for (qw(render_as label hints length mandatory sort_order)) {<br>+ for (qw(render_as label hints length distinct mandatory sort_order)) {<br> <br> if ( defined $column->$_ ) {<br> $info->{$_} = $column->$_;
<br>Index: lib/Jifty/Action.pm<br>===================================================================<br>--- lib/Jifty/Action.pm (revision 1124)<br>+++ lib/Jifty/Action.pm (working copy)<br>@@ -699,6 +699,15 @@<br> }
<br> }<br> <br>+ if ( $field_info->{distinct} && defined $value) {<br>+ my $u = $self->record_class->new();<br>+ $u->load_by_cols( $field => $value);<br>+ if ($u->id) {<br>+ return $self->validation_error(
<br>+ $field => q{There is already an entry with that value} );<br>+ }<br>+ }<br>+<br> # If we have a set of allowed values, let's check that out.<br> # XXX TODO this should be a validate_valid_values sub
<br> if ( $value && $field_info->{valid_values} ) {<br><br>