throwCheckedIfOrNull method
데이터가 null이거나 특정 조건(condition)을 만족할 경우 CheckedException을 발생시킵니다.
throwCheckedIfNull을 먼저 수행하여 값의 존재를 보장한 뒤 비즈니스 조건을 검사합니다.
값이 반드시 존재해야 하며, 동시에 특정 규칙을 통과해야 하는 복합 검증 시나리오에 적합합니다.
Throws a CheckedException if the value is null or satisfies the specified
condition.
Ensures the existence of the value first, then validates the business condition.
Implementation
T throwCheckedIfOrNull(
bool Function(T value) condition, {
required String prefix,
({String english, String locale}) message = (english: '', locale: ''),
}) {
final T value = throwCheckedIfNull(prefix: prefix, message: message);
if (condition(value)) {
throw GenericCheckedException(value: value, prefix: prefix, message: message);
}
return value;
}