Rye reference: Validation

Validation dialect

Functions that convert between Rye value types.

validate (required/optional)

Pure Builtin(1): Tries to change a Rye value to a word with same name.

{ "a" "1" } .dict .validate { a: required }
; returns [
;  a: "1"
; ]
{ "a" "1" } .dict .validate { a: required integer }
; returns [
;  a: 1
; ]
{ "a" "1" } .dict .validate { b: required } |disarm |type?
; returns error
{ "a" "1" } .dict .validate { b: optional "B" }
; returns [
;  b: "B"
; ]

validate (types)

Pure Builtin(1): Tries to change a Rye value to a word with same name.

{ "a" "1" } .dict .validate { a: required }
; returns [
;  a: "1"
; ]
{ "a" "1" } .dict .validate { a: required string }
; returns [
;  a: "1"
; ]
{ "a" "1" } .dict .validate { a: required integer }
; returns [
;  a: 1
; ]
{ "a" "1.0" } .dict .validate { a: required decimal }
; returns [
;  a: 1.000000
; ]
{ "e" "rye@ryelang.org" } .dict .validate { e: required email }
; returns [
;  e: "rye@ryelang.org"
; ]
{ } .dict .validate { b: optional "1" integer }
; returns [
;  b: 1
; ]
{ } .dict .validate { b: optional "2" decimal }
; returns [
;  b: 2.000000
; ]

validate (calc/check)

Pure Builtin(1): Tries to change a Rye value to a word with same name.

{ "a" "AAA" } .dict .validate { a: required integer calc { + 1 } } |disarm |type?
; returns error
{ "a" "100" } .dict .validate { a: required integer calc { + 1 } }
; returns [
;  a: 101
; ]

Regular expressions

Functions for handling and working with Context.

regexp

Builtin(1): TODODOC

regexp "[0-9]" |type?
; returns native

is-match

regexp "[0-9]" |is-match "5"
; returns 1
regexp "[0-9]" |is-match "a"
; returns 0

match?

regexp "[0-9]+c+" |match? "aa33bb55cc"
; returns "55cc"

submatch?

regexp "([0-9]+)" |submatch? "aa33bb44cc"
; returns "33"

submatches?

regexp "([0-9]+).*?(c+)" |submatches? "aa33bb55cc"
; returns { "33" "cc" }

find-all

regexp "([0-9]+)" |find-all "aa33bb55cc"
; returns { "33" "55" }

replace-all

regexp "([0-9]+)" |replace-all "aa33bb55cc" "XX"
; returns "aaXXbbXXcc"