Skip to content

Commit

Permalink
Merge pull request #13 from VenusProtocol/feat/add-nonzero-value-check
Browse files Browse the repository at this point in the history
Feat function for Non-Zero Value Checks
  • Loading branch information
chechu authored Jan 9, 2024
2 parents b00718c + 8e5787b commit 12d35c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions contracts/validators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity 0.8.13;
/// @notice Thrown if the supplied address is a zero address where it is not allowed
error ZeroAddressNotAllowed();

/// @notice Thrown if the supplied value is 0 where it is not allowed
error ZeroValueNotAllowed();

/// @notice Checks if the provided address is nonzero, reverts otherwise
/// @param address_ Address to check
/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address
Expand All @@ -12,3 +15,12 @@ function ensureNonzeroAddress(address address_) pure {
revert ZeroAddressNotAllowed();
}
}

/// @notice Checks if the provided value is nonzero, reverts otherwise
/// @param value_ Value to check
/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0
function ensureNonzeroValue(uint256 value_) pure {
if (value_ == 0) {
revert ZeroValueNotAllowed();
}
}

0 comments on commit 12d35c2

Please sign in to comment.