package Daje::Workflow::Checks::Mandatory;
use Mojo::Base 'Daje::Workflow::Common::Checks::Base', -base, -signatures;


sub check($self) {
    my $result = 1;
    if (length($self->checks()) > 0) {
        my @fields = split(',', $self->checks());
        my $length = scalar @fields;
        for (my $i = 0; $i < $length; $i++) {
            if (!exists $self->context->{context}->{$fields[$i]}) {
                $result = 0;
                $self->error->add_error("Mandatory field '$fields[$i]' is missing")
            }
        }
    }
    return $result;
}

1;




#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME

Daje::Workflow::Checks::Mandatory


=head1 DESCRIPTION

pod generated by Pod::Autopod - keep this line to make pod updates possible ####################


=head1 REQUIRES

L<Mojo::Base> 


=head1 METHODS

=head2 check($self)

 check($self)();


=cut

