jQuery looping on fields after validation
Why not just iterate over the inputs, and if the values of the id attribute exists in data then add the error class and show the affiliated error message, otherwise add the valid class and clear the error message? 

When the DOM is ready, the input values can be stored in a variable:

$(function() { //DOM-ready
    //cache the inputs from the DOM so as to minimize DOM queries.
    const inputs = $(":input");


Note that texetarea, select were removed from the selector because the jQuery :input selector includes those.

Then inputs can be used for registering the blur callback:

inputs.on('blur', function(ev) {


And then in the success callback of the AJAX request, inputs can be used again with $.each():

success: function(data) {
    if (data) {
      $.each(inputs, function(index, input) {


Then to determine if the field is invalid, check if the id
 attribute exists as a property of data. jQuery(input).prop() can be used to get the id property. Then data.hasOwnProperty() can be used to determine if the id property is set on data.

const id = jQuery(input).prop('id');
if (data.hasOwnProperty(id)) {
  jQuery(input).addClass('input-error')
      .removeClass('input-valid'); //chain calls for efficiency
  jQuery("#" + id + "-error").text(data[id]);
}
else {
  jQuery(input).removeClass('input-error')
      .addClass('input-valid');
  jQuery("#" + id + "-error").text("");
}


For a demonstration of this, see this plunker. Note that the AJAX response is not dynamic.

Actually, that last block could be re-written to utilize jQuery's toggleClass() method.

let message = '';
if (data.hasOwnProperty(id)) {
    message = data[id];
}
jQuery(input).toggleClass('input-error', message !== '')
    .toggleClass('input-valid', message === '');
jQuery("#" + id + "-error").text(message);


See a demonstration of that in this plunker.