@@ -941,6 +941,11 @@ use serde_json::Value;
941941/// # Panics
942942///
943943/// This function panics if an invalid schema is passed.
944+ ///
945+ /// This function **must not** be called from within an async runtime if the schema contains
946+ /// external references that require network requests, or it will panic when attempting to block.
947+ /// Use `async_validator_for` for async contexts, or run this in a separate blocking thread
948+ /// via `tokio::task::spawn_blocking`.
944949#[ must_use]
945950#[ inline]
946951pub fn is_valid ( schema : & Value , instance : & Value ) -> bool {
@@ -968,6 +973,11 @@ pub fn is_valid(schema: &Value, instance: &Value) -> bool {
968973/// # Panics
969974///
970975/// This function panics if an invalid schema is passed.
976+ ///
977+ /// This function **must not** be called from within an async runtime if the schema contains
978+ /// external references that require network requests, or it will panic when attempting to block.
979+ /// Use `async_validator_for` for async contexts, or run this in a separate blocking thread
980+ /// via `tokio::task::spawn_blocking`.
971981#[ inline]
972982pub fn validate < ' i > ( schema : & Value , instance : & ' i Value ) -> Result < ( ) , ValidationError < ' i > > {
973983 validator_for ( schema)
@@ -994,6 +1004,11 @@ pub fn validate<'i>(schema: &Value, instance: &'i Value) -> Result<(), Validatio
9941004/// # Panics
9951005///
9961006/// This function panics if an invalid schema is passed.
1007+ ///
1008+ /// This function **must not** be called from within an async runtime if the schema contains
1009+ /// external references that require network requests, or it will panic when attempting to block.
1010+ /// Use `async_validator_for` for async contexts, or run this in a separate blocking thread
1011+ /// via `tokio::task::spawn_blocking`.
9971012#[ must_use]
9981013#[ inline]
9991014pub fn evaluate ( schema : & Value , instance : & Value ) -> Evaluation {
@@ -1022,6 +1037,13 @@ pub fn evaluate(schema: &Value, instance: &Value) -> Evaluation {
10221037/// # Errors
10231038///
10241039/// Returns an error if the schema is invalid or external references cannot be resolved.
1040+ ///
1041+ /// # Panics
1042+ ///
1043+ /// This function **must not** be called from within an async runtime if the schema contains
1044+ /// external references that require network requests, or it will panic when attempting to block.
1045+ /// Use `async_validator_for` for async contexts, or run this in a separate blocking thread
1046+ /// via `tokio::task::spawn_blocking`.
10251047pub fn validator_for ( schema : & Value ) -> Result < Validator , ValidationError < ' static > > {
10261048 Validator :: new ( schema)
10271049}
@@ -1065,6 +1087,10 @@ pub async fn async_validator_for(schema: &Value) -> Result<Validator, Validation
10651087/// options for JSON Schema validation. You can use this builder to specify
10661088/// the draft version, set custom formats, and more.
10671089///
1090+ /// **Note:** When calling [`ValidationOptions::build`], it **must not** be called from within
1091+ /// an async runtime if the schema contains external references that require network requests,
1092+ /// or it will panic. Use `async_options` for async contexts.
1093+ ///
10681094/// # Examples
10691095///
10701096/// Basic usage with draft specification:
0 commit comments