tracking-code-which-will-go-to-the-HEAD FLAMEAL Documentation client/src/components/SearchTransaction/validateSearch.js

Source

client/src/components/SearchTransaction/validateSearch.js

/**
 * Function to validate the input of the search field
 * @category Search Transactions
 * @function validateSearch
 * @param {Object} value - the input to be validated
 * @returns
 */
export default function validateSearch(value) {
  //create an empty array
  let error = "";

  if (value.length === 0) {
    //setting the error in case the field is empty
    error = "Address required";
  } else if (value.length > 42) {
    //setting the error in case the input is over 30 caracters to prevent overloading the blockchain network
    error = "Address too long";
  } else if (value.length < 42) {
    error = "Address too short";
  }
  return error;
}