Design the regulator to measure the output current with some current sense method, and when it gets close to the current setpoint, the regulator automatically reduces the amount of power transferred to the output. When the output looks like a short circuit, allow exactly the setpoint current to flow. (current limiting)