in the first case I would check the string length

require(bytes(hash).length > 0);

in the second case just check against the void address

require(hashes[hash] == address(0x0));
Answer from qbsp on Stack Exchange
🌐
Medium
hamilton-cyber.medium.com › empty-of-struct-string-array-or-mapping-in-solidity-43f09a4d5fb
Empty of Struct, String, Array or Mapping in Solidity | by Hamilton Cyber | Medium
October 20, 2022 - Empty of Struct, String, Array or Mapping in Solidity There is no concept of NULL in solidity. Empty of a struct, string, array or mapping in solidity is treated as zero-value of each type, e.g. zero …
🌐
Edureka Community
edureka.co › home › community › categories › blockchain › are there null like thing in solidity
Are there null like thing in solidity | Edureka Community
September 21, 2018 - 21552/are-there-null-like-thing-in-solidity · If a buyer is not recorded int the buyer mapping, then buyerNum++; but I don'k how to tell whether a buyer is in the mapping
🌐
DEV Community
dev.to › fassko › absence-of-null-in-solidity-3h1i
Absence of null in Solidity - DEV Community
August 31, 2022 - The concept of undefined, null, nil, None, etc. exists in languages like JavaScript, Java, Python, Swift, .etc. but it does not exist in Solidity. In Solidity, we can call it zero or default value concept instead.
🌐
Readthedocs
solidity.readthedocs.io › en › v0.5.3 › types.html
Types — Solidity 0.5.3 documentation
June 9, 2022 - In addition, types can interact with each other in expressions containing operators. For a quick reference of the various operators, see Order of Precedence of Operators. The concept of “undefined” or “null” values does not exist in Solidity, but newly declared variables always have ...
Find elsewhere
🌐
Metaschool
metaschool.so › home › answers › is there a null in solidity programming language?
Is There a Null in Solidity Programming Language? -
February 9, 2024 - We don’t have the null in Solidity. Instead, we have a default or zero concept. By default, each variable gets filled by the default value.
🌐
GitHub
github.com › IoBuilders › solidity-string-util
GitHub - IoBuilders/solidity-string-util: A simply Solidity library for common string operations · GitHub
pragma solidity ^0.5.0; import "solidity-string-util/contracts/StringUtil.sol"; contract YourContract { using StringUtil for string; // your custom code }
Author   IoBuilders
🌐
Better Programming
betterprogramming.pub › absence-of-null-in-solidity-bc80ce5e5b09
Absence of Null in Solidity
September 2, 2022 - The concept of undefined, null, nil, None, etc. exists in languages like JavaScript, Java, Python, Swift, .etc. but it does not exist in Solidity. In Solidity, we can call it zero or default value concept instead.
🌐
Solidity
docs.soliditylang.org › en › v0.8.12 › types.html
Types — Solidity 0.8.12 documentation
April 14, 2022 - In addition, types can interact with each other in expressions containing operators. For a quick reference of the various operators, see Order of Precedence of Operators. The concept of “undefined” or “null” values does not exist in Solidity, but newly declared variables always have ...
🌐
GitHub
github.com › miguelmota › solidity-idiosyncrasies
GitHub - miguelmota/solidity-idiosyncrasies: Solidity gotchas, pitfalls, limitations, and idiosyncrasies.
November 30, 2020 - pragma solidity ^0.4.4; contract MyContract { } All primitive data types are initialized with default values; there is no "null" data type (like in JavaScript). contract MyContract { int n; // 0 string str; // "" address addr; // 0x00000000...
Starred by 345 users
Forked by 45 users
Languages   Solidity 85.7% | JavaScript 14.3% | Solidity 85.7% | JavaScript 14.3%
🌐
Substack
kristaps.substack.com › p › absence-of-null-in-solidity
Absence of null in Solidity - by Kristaps Grinbergs
September 1, 2022 - There is another way to achieve that, but that we are going to talk about in one of the future posts. Solidity programming language doesn't have the nullability feature, which is common in many languages like Swift and JavaScript.
🌐
Solidity
docs.soliditylang.org › en › v0.8.9 › types.html
Types — Solidity 0.8.9 documentation
In addition, types can interact with each other in expressions containing operators. For a quick reference of the various operators, see Order of Precedence of Operators. The concept of “undefined” or “null” values does not exist in Solidity, but newly declared variables always have ...
🌐
Solidity
docs.soliditylang.org › en › v0.8.20 › types.html
Types — Solidity 0.8.20 documentation
December 16, 2022 - In addition, types can interact with each other in expressions containing operators. For a quick reference of the various operators, see Order of Precedence of Operators. The concept of “undefined” or “null” values does not exist in Solidity, but newly declared variables always have ...