diff --git a/lib/src/fnc/is.rs b/lib/src/fnc/is.rs index 02ec86df..9188fdaf 100644 --- a/lib/src/fnc/is.rs +++ b/lib/src/fnc/is.rs @@ -4,6 +4,7 @@ use once_cell::sync::Lazy; use regex::Regex; use semver::Version; use std::char; +use url::Url; use uuid::Uuid; #[rustfmt::skip] static LATITUDE_RE: Lazy = Lazy::new(|| Regex::new("^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$").unwrap()); @@ -59,6 +60,11 @@ pub fn semver((arg,): (String,)) -> Result { Ok(Version::parse(arg.as_str()).is_ok().into()) } +#[inline] +pub fn url((arg,): (String,)) -> Result { + Ok(Url::parse(&arg).is_ok().into()) +} + #[inline] pub fn uuid((arg,): (Value,)) -> Result { Ok(match arg { diff --git a/lib/src/fnc/mod.rs b/lib/src/fnc/mod.rs index 284c61f9..744732bd 100644 --- a/lib/src/fnc/mod.rs +++ b/lib/src/fnc/mod.rs @@ -101,6 +101,7 @@ pub fn synchronous(ctx: &Context<'_>, name: &str, args: Vec) -> Result is::longitude, "is::numeric" => is::numeric, "is::semver" => is::semver, + "is::url" => is::url, "is::uuid" => is::uuid, // "math::abs" => math::abs, diff --git a/lib/src/sql/function.rs b/lib/src/sql/function.rs index c5b87174..575f988f 100644 --- a/lib/src/sql/function.rs +++ b/lib/src/sql/function.rs @@ -309,6 +309,7 @@ fn function_is(i: &str) -> IResult<&str, &str> { tag("is::longitude"), tag("is::numeric"), tag("is::semver"), + tag("is::url"), tag("is::uuid"), ))(i) }