[html-formfu] How to best pass the resultset object to DBIC validator callbacks?

Ascii King tech at swattermatter.com
Thu Jun 4 19:40:50 GMT 2009


This Validator references a bit of code (validator_unique_url) that 
presumably calls the database to check to see if the value is unique. 
Would someone be able to show what this code would actually look like? I 
have the rest of the validator example from this thread.
> Then in MyApp::Schema::ResultSet::Urls,
>
> use base qw/MyApp::Schema::Base::ResultSet/;
> sub validator_unique_url {
>    my $value = shift;
>    .... how do I get at the DB?
> }
Also, in the following sub, what would be an example of a context? Would 
it be 'MyApp::Schema' or 'MyApp::Schema::TableName'?

>>    sub validate_value {
>>        my ( $self, $value, $params ) = @_;
>>
>>        my $c = $self->form->stash->{context};
>>
>>        return $c->model('DBIC::Urls')->validator_unique_url($value);
>>    }





More information about the HTML-FormFu mailing list