valid<T> function

T? valid<T>(
  1. T value,
  2. List<bool> validations(
    1. T?
    )?, [
  3. string? throwErrorMessage
])

Validates a value of type T using a list of validation functions. The value is considered valid if at least one of the validation functions returns true. If the value is valid, it is returned; otherwise, null is returned.

Implementation

T? valid<T>(T value, List<bool> Function(T?)? validations, [string? throwErrorMessage]) => isValid(value, customValidator: validations)
    ? value
    : throwErrorMessage.isNotBlank
        ? throw Exception(throwErrorMessage)
        : null;