module
Amber::Support::TextFormats
Overview
Checks for the text formats Amber validates, each one a single left-to-right pass over the bytes. Their cost grows with the length of the text whatever the text contains, and they use no regex engine.
Defined in:
amber/support/text_formats.crClass Method Summary
-
.email?(text : String) : Bool
[email protected]: the strict shape. -
.hostname?(text : String) : Bool
Labels of 1 to 63 letters, digits and hyphens, joined by dots, where each label begins and ends with a letter or digit.
-
.ipv4?(text : String) : Bool
Four dot-separated numbers from 0 to 255, each one to three digits.
-
.ipv6?(text : String) : Bool
Eight groups of one to four hex digits, or up to seven with one
::, plus three special shapes:fe80:with a%zone,::or::ffff:or::ffff:0:before an IPv4 address, and one to four groups and::before an IPv4 address. -
.location_prefix?(text : String) : Bool
True when text begins with a location: an optional
http://orhttps://, then host characters containing a dot followed by two or more letters or digits. -
.loose_email?(text : String) : Bool
[email protected]: one@, no whitespace, and a dot with text on both sides somewhere after the@. -
.phone?(text : String) : Bool
E.164: an optional
+, a digit from 1 to 9, then 5 to 14 more digits. -
.time_of_day?(text : String) : Bool
H:MM:SSorHH:MM:SSon a 24-hour clock. -
.uuid?(text : String) : Bool
123e4567-e89b-12d3-a456-426614174000, in either case. -
.web_address?(text : String) : Bool
The relaxed web address shape: an optional
http://orhttps://, then letters, digits,.and-, a dot, and two lowercase letters or dots.
Class Method Detail
[email protected]: the strict shape. The last domain label is two or more letters.
Labels of 1 to 63 letters, digits and hyphens, joined by dots, where each label begins and ends with a letter or digit.
Four dot-separated numbers from 0 to 255, each one to three digits. Leading zeros are accepted.
Eight groups of one to four hex digits, or up to seven with one ::, plus three
special shapes: fe80: with a %zone, :: or ::ffff: or ::ffff:0: before
an IPv4 address, and one to four groups and :: before an IPv4 address.
True when text begins with a location: an optional http:// or https://,
then host characters containing a dot followed by two or more letters or digits.
Only the beginning is judged; String#url? accepts whatever follows it.
[email protected]: one @, no whitespace, and a dot with text on
both sides somewhere after the @.
E.164: an optional +, a digit from 1 to 9, then 5 to 14 more digits.
123e4567-e89b-12d3-a456-426614174000, in either case.
The relaxed web address shape: an optional http:// or https://, then letters,
digits, . and -, a dot, and two lowercase letters or dots. The rest may hold
word characters, spaces, /, . and -.