独自の意味を持つテキスト
| 型 | 保持する内容 | 整理済み | メソッド |
|---|---|---|---|
email |
joan@example.com のようなアドレスです。 |
空白は取り除かれ、ドメインは小文字に変換されます。 | .local, .domain |
handle |
@ の後に、文字、数字、_、.、または-が続き、最大30個まで指定できます。 |
小文字に変換されます。 | .name(@を除く) |
uuid |
バージョン1から8までのUUID、および nil UUID と max UUID。 | 8-4-4-4-12 に小文字に変換されます。urn:uuid:、波かっこ、および 32 桁の 16 進数も読み取られます。 |
.version, .timestamp |
regex |
フラグ i、m、s、x を指定した正規表現です。 |
->test(), ->match(), ->match_all(), ->replace(), ->split(), .pattern, .flags |
|
password |
秘密です。画面には表示されません。 | ->hash(), ->verify(), ->needs_rehash(), ->strength(), ->is_strong(), ->reveal() |
ネイティブの値も依然としてテキストであり、整理された後には同じテキストと等しいと比較されます。メールアドレスはドメイン部分が小文字化された状態で比較されます。意味のある文字列メソッドは引き続き使用でき、エディターもそれらだけを候補として提示します:
| 型 | 保持される文字列メソッド |
|---|---|
email |
contains, starts_with, ends_with, index_of, count, lower, upper, slice, split, replace, matches, truncate, pad, escape, url_encode, markdown_escape |
handle |
contains, starts_with, ends_with, count, upper, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
uuid |
contains, starts_with, ends_with, upper, slice, split, pad, escape, url_encode, markdown_escape |
regex |
contains, starts_with, ends_with, count, escape, markdown_escape |
url |
contains, starts_with, ends_with, index_of, count, split, replace, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
domain |
contains, starts_with, ends_with, index_of, count, split, upper, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
ip |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
cidr |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
mac |
contains, starts_with, ends_with, index_of, count, split, upper, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
slug |
contains, starts_with, ends_with, index_of, count, split, upper, replace, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
file_path |
contains, starts_with, ends_with, index_of, count, split, lower, upper, replace, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
slash_path |
contains, starts_with, ends_with, index_of, count, split, lower, upper, replace, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
semver |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
mime |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
hex |
contains, starts_with, ends_with, index_of, count, upper, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
base64 |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
jwt |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
json |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
csv |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
phone |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
country |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
currency |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
locale |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
timezone |
contains, starts_with, ends_with, index_of, count, split, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
duration |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
date_format |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
cron |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
color |
contains, starts_with, ends_with, index_of, count, upper, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
iban |
contains, starts_with, ends_with, index_of, count, slice, matches, truncate, pad, escape, url_encode, markdown_escape |
port、card、またはpasswordは何も保持しません。->to_date()などのその他のものは(uuid に対して使う場合など)、エディターで報告され、スクリプトの実行時に失敗します。それでもテキストに対して使うには、先に->to_string()を呼び出します:$id->to_string()->to_date()。
<let name="email" type="email" value="' Joan.Smith@Example.COM '" />
<echo>{ $email } { $email.local } at { $email.domain }</echo>
<echo>{ $email == 'Joan.Smith@EXAMPLE.com' }</echo>
<let name="who" type="handle" value="@Joan_S" />
<echo>{ $who } { $who.name }</echo>
<let name="id" value="@uuid()" />
<let name="key" value="@uuid(v: 8, name: 'joan@example.com')" />
<echo>{ $id.version } { $key.version } { $key == @uuid(v: 8, name: 'joan@example.com') }</echo>$email: email = ' Joan.Smith@Example.COM '
echo "{ $email } { $email.local } at { $email.domain }"
echo "{ $email == 'Joan.Smith@EXAMPLE.com' }"
$who: handle = @Joan_S
echo "{ $who } { $who.name }"
$id = @uuid()
$key = @uuid(v: 8, name: 'joan@example.com')
echo "{ $id.version } { $key.version } { $key == @uuid(v: 8, name: 'joan@example.com') }"テキストが UUID かどうかを確認するには、$text->is_a(uuid) を使用します。$text as uuid を使用して変換し、無効なテキストをエラーとして報告します。
@uuid() はランダムなバージョン 4 の UUID を生成します。@uuid(v: 7) は時刻順のバージョン 7 の UUID を生成します。データベースのキーによく使われるのは、新しいものほど古いものより後ろに並ぶためです。.timestamp は生成された時刻を表します。@uuid(v: 8) は同じく時刻順のバージョン 8 の UUID を生成します。name: を使うと、その名前に対しては毎回同じ UUID になります。namespace: は、異なる場所から来た名前同士を区別するために使います。
誤った形式の値は、作成された箇所で失敗し、その理由を示すShapeエラーが発生します:
$email doesn't fit email: 'joan@' isn't an email: there's nothing after the @.エディターは、入力中に同じ問題を値の位置で報告します(KS5012)。