Is it possible to have an optional field and apply validation to the field only when the user has entered something into the field?

Is it possible to have an optional field and apply validation to the field only when the user has entered something into the field?

Solved my own problem
