package solutions.tretter.mindmachine.session

import solutions.tretter.mindmachine.domain.SessionConfig
object SessionValidator {
    fun validate(config: SessionConfig): String? {
        if (config.durationSec !in 60..(60 * 60)) return "Duration must be 1 minute to 60 minutes."
        if (config.flashIntervalMs !in 50..2000) return "Flash interval must be 0.05 to 2.00 seconds."
        val carrier = config.carrierFrequencyHz
        if (!carrier.isFinite() || carrier < ParameterRanges.CARRIER_HZ_MIN || carrier > ParameterRanges.CARRIER_HZ_MAX) {
            return "Carrier frequency must be between ${ParameterRanges.CARRIER_HZ_MIN.toInt()} and ${ParameterRanges.CARRIER_HZ_MAX.toInt()} Hz."
        }
        if (config.binauralDifferenceHz !in 0.5f..20f) return "Binaural difference must be between 0.5 and 20."
        return null
    }
}
