# perldoc > Moose::Meta::TypeCoercion

---
type: CommandReference
command: Moose::Meta::TypeCoercion
mode: perldoc
section: ''
source: perldoc
---

## Quick Reference

- `Moose::Meta::TypeCoercion->new(type_constraint => $tc)` — Create a new coercion object
- `$coercion->add_type_coercions('TypeName' => sub { ... })` — Add a coercion mapping for a type
- `$coercion->coerce($value)` — Apply the first matching coercion to a value
- `$coercion->has_coercion_for_type('TypeName')` — Check if a coercion exists for a named type

## Name

Moose::Meta::TypeCoercion - The Moose Type Coercion metaclass

## Synopsis

perl
Moose::Meta::TypeCoercion->new( type_constraint => $type_constraint )
$coercion->add_type_coercions( $type_name => sub { ... }, ... )
$coercion->coerce( $value )
## Options

- `new(%options)` — Creates a new type coercion object. Option `type_constraint` is a [Moose::Meta::TypeConstraint](https://metacpan.org/pod/Moose::Meta::TypeConstraint) object for the type being coerced *to*.
- `$coercion->type_coercion_map` — Returns an array reference alternating between type names and subroutine references (coercions). Order is the order coercions were added.
- `$coercion->type_constraint` — Returns the [Moose::Meta::TypeConstraint](https://metacpan.org/pod/Moose::Meta::TypeConstraint) passed to the constructor.
- `$coercion->has_coercion_for_type($type_name)` — Returns true if the coercion can coerce the named type.
- `$coercion->add_type_coercions( $type_name => $sub, ... )` — Adds one or more type name / coercion subroutine pairs. Throws an exception if the type already has a mapping.
- `$coercion->coerce($value)` — Applies the first valid coercion found. If the value could match multiple types, the first added coercion is used.
- `Moose::Meta::TypeCoercion->meta` — Returns a [Class::MOP::Class](https://metacpan.org/pod/Class::MOP::Class) instance for this class.

## See Also

- [Moose::Meta::TypeConstraint](https://metacpan.org/pod/Moose::Meta::TypeConstraint)
- [Class::MOP::Class](https://metacpan.org/pod/Class::MOP::Class)
- [Moose](https://metacpan.org/pod/Moose)