The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Raisin::Types::Base - Base class for Raisin::Types.

SYNOPSIS

package Raisin::Types::Integer;
use base 'Raisin::Types::Base';

sub regex { qr/^\d+$/ }
sub check {
    my ($self, $v) = @_;
    length($v) <= 10 ? 1 : 0
}
sub in {
    my ($self, $v) = @_; # REF
    $$v = sprintf 'INT:%d', $$v;
}

package main;

# validate 10.1
use Raisin::Types::Integer;

warn Raisin::Types::Integer->new(1234) ? 'valid' : 'invalid';
warn Raisin::Types::Integer->new(10.1) ? 'valid' : 'invalid';

DESCRIPTION

Base class for each Raisin type.

Contains two base methods: check and in.

METHODS

regex

Type regex.

check

Check value.

in

Apply some actions on the value.