validatePinSize function
Validates pin box size within configured bounds.
Implementation
double validatePinSize(
double? size, {
required double defaultValue,
bool? enableSecurity,
}) {
final shouldValidate = enableSecurity ?? OTPSecurityConfig.enforceValidation;
if (size == null) return defaultValue;
if (!shouldValidate) return size;
if (size > OTPSecurityConfig.maxPinSize) {
if (OTPSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC OTP Security] Pin size $size above max ${OTPSecurityConfig.maxPinSize}',
);
}
return OTPSecurityConfig.maxPinSize;
}
if (size < OTPSecurityConfig.minPinSize) {
if (OTPSecurityConfig.enableSecurityLogging) {
debugPrint(
'[SAC OTP Security] Pin size $size below min ${OTPSecurityConfig.minPinSize}',
);
}
return OTPSecurityConfig.minPinSize;
}
return size;
}