Coder Social home page Coder Social logo

moox-should's Introduction

NAME

MooX::Should - optional type restrictions for Moo attributes

VERSION

version v0.1.4

SYNOPSIS

use Moo;

use MooX::Should;
use Types::Standard -types;

has thing => (
  is     => 'ro',
  should => Int,
);

DESCRIPTION

This module is basically a shortcut for

use Devel::StrictMode;
use PerlX::Maybe;

has thing => (
        is  => 'ro',
  maybe isa => STRICT ? Int : undef,
);

It allows you to completely ignore any type restrictions on Moo attributes at runtime, or to selectively enable them.

Note that you can specify a (weaker) type restriction for an attribute:

use Types::Common::Numeric qw/ PositiveInt /;
use Types::Standard qw/ Int /;

has thing => (
  is     => 'ro',
  isa    => Int,
  should => PositiveInt,
);

but this is equivalent to

use Devel::StrictMode;

has thing => (
  is     => 'ro',
  isa    => STRICT ? PositiveInt : Int,
);

SEE ALSO

SOURCE

The development version is on github at https://github.com/robrwo/MooX-Should and may be cloned from git://github.com/robrwo/MooX-Should.git

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/MooX-Should/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Theo van Hoesel [email protected]

Originally written by Robert Rothenberg [email protected].

CONTRIBUTORS

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018-2021 by Robert Rothenberg.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.