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

Source

client/src/components/SearchTransaction/validateSearch.js

  1. /**
  2. * Function to validate the input of the search field
  3. * @category Search Transactions
  4. * @function validateSearch
  5. * @param {Object} value - the input to be validated
  6. * @returns
  7. */
  8. export default function validateSearch(value) {
  9. //create an empty array
  10. let error = "";
  11. if (value.length === 0) {
  12. //setting the error in case the field is empty
  13. error = "Address required";
  14. } else if (value.length > 42) {
  15. //setting the error in case the input is over 30 caracters to prevent overloading the blockchain network
  16. error = "Address too long";
  17. } else if (value.length < 42) {
  18. error = "Address too short";
  19. }
  20. return error;
  21. }