Solenoid valve with optocoupler and transistor

Not a problem, as long as you stay under the 20volt absolute max for the gate (see datasheet).
Leo..