Solenoid valve with optocoupler and transistor

Of course. That 2A is simply the limit of what it can supply.