Aion

 view release on metacpan or  search on metacpan

lib/Aion/Types.md  view on Meta::CPAN

	subtype 'IntOrArrayRef[len, B]',
		as Int & Range[5, A]
			| ArrayRef[B & Len[A]];
}

35 ~~ IntOrArrayRef[35, Tel] # -> 1
35 ~~ IntOrArrayRef[34, Tel] # -> ""

'+23456789'  ~~ Tel # -> 1
'+234567890' ~~ Tel # -> 1
'+23456789'  ~~ (Tel & Len[9]) # -> 1
'+234567890' ~~ (Tel & Len[9]) # -> ""

['+23456789',  '+23456789'] ~~ IntOrArrayRef[9, Tel] # -> 1
['+234567890', '+23456789'] ~~ IntOrArrayRef[9, Tel] # -> ""

"" ~~ IntOrArrayRef[8, Tel]  # -> ""


coerce IntOrArrayRef[35, Str], from Num, via { int($_ + .5) };

IntOrArrayRef([35, Str])->coerce(5.5) # => 6

5.5 >> IntOrArrayRef[35, Str] # => 6

(Tel & Len[9]) < (Tel & Len[10]) # => 1
```

# DESCRIPTION

Этот модуль экспортирует подпрограммы:

* `subtype`, `as`, `init_where`, `where`, `awhere`, `message` — для создания валидаторов.
* `SELF`, `ARGS`, `A`, `B`, `C`, `D`, `M`, `N` — для использования в валидаторах типа и его аргументов.
* `coerce`, `from`, `via` — для создания конвертора значений из одного класса в другой.

Иерархия валидаторов:

```text
Any
	Control
		Union[A, B...]
		Intersection[A, B...]
		Exclude[A...]
		Option[A]
		Wantarray[A, B]
	Item
		External[type]
		Bool
		BoolLike
		Enum[e...]
		Maybe[A]
		Undef
		Defined
			Value
				Version
				Str
					Uni
					Bin
					NonEmptyStr
					StartsWith[start]
					EndsWith[end]
					Email
					Tel
					Url
					Path
					Html
					StrDate
					StrDateTime
					StrMatch[regexp]
					PackageName
						ClassName
						RoleName
					Join[separator]
					Split[separator]
					StrRat
					Num
						PositiveNum
						Int
							PositiveInt
							Nat
			Ref
				Tied`[class]
				LValueRef
				FormatRef
				CodeRef
					NamedCode[subname]
					ProtoCode[prototype]
					ForwardRef
					ImplementRef
					Isa[A...]
				RegexpRef
				ValueRef`[A]
					ScalarRef`[A]
					RefRef`[A]
				GlobRef
					FileHandle
				ArrayRef`[A]
					Tuple[A...]
					CycleTuple[A...]
				HashRef`[A]
					Map[A => B]
					Dict[k => A, ...]
				Object`[class]
					Me
					Rat
				RegexpLike
				CodeLike
				ArrayLike`[A]
					Lim[from?, to]
				HashLike`[A]
					HasProp[p...]
					LimKeys[from?, to]
			Like
				HasMethods[m...]
				Overload`[m...]
				InstanceOf[class...]
				ConsumerOf[role...]
				StrLike
					Len[from?, to]
				NumLike



( run in 1.963 second using v1.01-cache-2.11-cpan-a49fcb8fa48 )