Settings API – input always updates over validation

Looks like your validation argument is negative.

if ($foo != "") { //means if foo not equal to empty space
  // do something when not empty
  // here you are setting an error
} else {
  // do something when empty
  // here you are trying to do your normal operation
}

You are setting an error when you have data and then trying to process data when you have none.

try changing your != to ==

or change the order in which you process things in the if