return (value, path = new Path()) => {
    try {
      const checked = checkValue(value);
      return checked != null
        ? success(checked, [])
        : failure(failureMessage, path);
    } catch (error) {
      return failure(error.message, path);
    }
  }
helper to create a custom checker from a provided function.
If the function returns a non-nullable value, the checker succeeds.

```jsx
const myClassChecker = custom(x => x instanceof MyClass ? x : null);
```

Nullable custom types can be created by composing with `nullable()` or
`voidable()` checkers:

```jsx
const maybeMyClassChecker =
  nullable(custom(x => x instanceof MyClass ? x : null));
```