You can provide a custom validation function to validate a value. This function should accept an Object? and return a bool.
The typedef for the custom validation function is:
With Code Generation, we can use the @WithCustomValidator annotation to provide a custom validation function.
Note: The custom validation function should be a top level function when using Code Generation. Anonymous functions are not supported due to Dart limitations.