package QBit::WebInterface::Controller::BEMHTML::Form::Field::domain;

use qbit;

use base qw(QBit::WebInterface::Controller::BEMHTML::Form::Field::input);

eval {require Exception::Form};

sub init {
    my ($self) = @_;

    $self->SUPER::init();

    $self->{'hint'} = 'example.com';
    $self->{'trim'} = 1;
}

sub clean {
    my ($self, $value) = @_;

    $value = $self->SUPER::clean($value);
    $value = get_domain($value);

    throw Exception::Form gettext('Invalid domain') unless defined($value);

    return $value;
}

1;
