confirms that f[expr] returns True, otherwise throwing an error to the nearest surrounding Enclose.


if expr is not confirmed, evaluates info and includes its value in the thrown error.


uses the specified tag for any thrown errors.


  • ConfirmBy[expr,] returns expr if expr is successfully confirmed.
  • ConfirmBy is dynamically scoped when given a tag. Otherwise, it is lexically scoped. »
  • The default value of info is Null.
  • Failure objects generated by ConfirmBy include the following fields:
  • "Information"info from ConfirmBy[expr,f,info,]
    "Expression"expr from ConfirmBy[expr,]
    "Function"f from ConfirmBy[expr,f,]
  • Values of these fields can be extracted using failure["prop"] or directly through Enclose[expr,"prop"].


open allclose all

Basic Examples  (2)

ConfirmBy[expr,f] gives expr if f[expr] evaluates to True:

Since "foo" is not a number, ConfirmBy stops evaluation and throws an error to the surrounding Enclose:

Create a function that checks its arguments:

Scope  (3)

ConfirmBy stops evaluation and returns to the matching Enclose when it throws an error:

info is only evaluated when expr cannot be confirmed:

Create a function that calls ConfirmBy with a tag so that it can be caught dynamically:

If no tag is given, ConfirmBy is lexically scoped:

Applications  (1)

Print a message when a failure is detected:

Properties & Relations  (1)

ConfirmBy can be emulated with ConfirmMatch:

Possible Issues  (3)

ConfirmBy must be given a tag or be within a lexical Enclose:

Untagged ConfirmBy works by replacing instances of the symbol ConfirmBy with a tagged variant:

Tagged ConfirmBy requires an Enclose with a matching tag:

Wolfram Research (2020), ConfirmBy, Wolfram Language function,


Wolfram Research (2020), ConfirmBy, Wolfram Language function,


@misc{reference.wolfram_2020_confirmby, author="Wolfram Research", title="{ConfirmBy}", year="2020", howpublished="\url{}", note=[Accessed: 16-January-2021 ]}


@online{reference.wolfram_2020_confirmby, organization={Wolfram Research}, title={ConfirmBy}, year={2020}, url={}, note=[Accessed: 16-January-2021 ]}


Wolfram Language. 2020. "ConfirmBy." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2020). ConfirmBy. Wolfram Language & System Documentation Center. Retrieved from