use
5.010;
ExistingDirectory ExistingFile TemplateObj
_NoDoubleSlashes _NoSpaces _NoForwardSlashes _NoSlashAtEnd _NotRootDir
_NoDots
ExistingSubdirectory ExistingDirectory_Spaceless
ExistingDirectory_SaneSlashes
DirectoryRef DirectoryTag
)
];
our
$VERSION
=
'1.500001'
;
$VERSION
=~ s/_//ms;
subtype ExistingDirectory,
as Dir,
where { -d
"$_"
},
message {
'Directory does not exist'
};
subtype _NoDoubleSlashes,
as ExistingDirectory,
where {
"$_"
!~ m{\\\\}ms },
message {
'cannot contain two consecutive slashes'
};
subtype _NoForwardSlashes,
as _NoDoubleSlashes,
where {
"$_"
!~ m{/}ms },
message {
'Forward slashes are not allowed'
};
subtype _NoSlashAtEnd,
as _NoForwardSlashes,
where {
"$_"
!~ m{\\\z}ms },
message {
'Cannot have a slash at the end'
};
subtype _NoDots,
as _NoSlashAtEnd,
where {
"$_"
!~ m{[.]}ms },
message {
'Cannot have a period'
};
subtype ExistingDirectory_SaneSlashes, as _NoDots;
coerce ExistingDirectory_SaneSlashes,
from Str, via { to_Dir(
$_
) },
from ArrayRef, via { to_Dir(
$_
) };
subtype _NoSpaces,
as _NoDots,
where {
"$_"
!~ m{\s}ms },
message {
'Spaces are not allowed'
};
subtype ExistingDirectory_Spaceless, as _NoSpaces;
coerce ExistingDirectory_Spaceless,
from Str, via { to_Dir(
$_
) },
from ArrayRef, via { to_Dir(
$_
) };
subtype _NotRootDir,
as _NoDots,
where {
"$_"
!~ m{:\z}ms },
message {
'Cannot be a root directory'
};
subtype ExistingSubdirectory, as _NotRootDir;
coerce ExistingSubdirectory,
from Str, via { to_Dir(
$_
) },
from ArrayRef, via { to_Dir(
$_
) };
subtype ExistingFile,
as File,
where { -f
"$_"
},
message {
'File does not exist'
};
coerce ExistingFile,
from Str, via { to_File(
$_
) },
from ArrayRef, via { to_File(
$_
) };
subtype TemplateObj,
as Object,
where {
$_
->isa(
'Template'
) },
message {
'Template is not the correct type of object'
};
class_type DirectoryRef, {
class
=>
'Perl::Dist::WiX::Tag::DirectoryRef'
};
class_type DirectoryTag, {
class
=>
'Perl::Dist::WiX::Tag::Directory'
};
1;