Help language development. Donate to The Perl Foundation

ORM::ActiveRecord cpan:GDONALD last updated on 2019-10-24

t/004-model-dynamic-errors.t6
use v6.d;
use lib 'lib';
use ORM::ActiveRecord::Model;
use Test;

class User is Model {
  submethod BUILD {
    self.validate: 'fname', { :presence, length => { min => 4 },
      message => '{model} {attribute} needs at least {value} characters' }
  }
}

plan 2;

%*ENV<DISABLE-SQL-LOG> = True;

my $user = User.build({fname => 'Foo'});
nok $user.is-valid;
ok $user.errors.fname eq 'User fname needs at least 4 characters';

User.destroy-all;