Skip to main content
added 3 characters in body
Source Link
Jesbus
  • 10.5k
  • 6
  • 38
  • 62

The bytes32 type is always exactly 32 bytes. Therefore, its length is always 32. It is unaware of whether it contains a string, number or something else.

I would recommend doing:

require(_name_name[0] != 0);

to verify that it does not represent an empty string.

The bytes32 type is always exactly 32 bytes. Therefore, its length is always 32. It is unaware of whether it contains a string, number or something else.

I would recommend doing:

require(_name != 0);

to verify that it does not represent an empty string.

The bytes32 type is always exactly 32 bytes. Therefore, its length is always 32. It is unaware of whether it contains a string, number or something else.

I would recommend doing:

require(_name[0] != 0);

to verify that it does not represent an empty string.

Source Link
Jesbus
  • 10.5k
  • 6
  • 38
  • 62

The bytes32 type is always exactly 32 bytes. Therefore, its length is always 32. It is unaware of whether it contains a string, number or something else.

I would recommend doing:

require(_name != 0);

to verify that it does not represent an empty string.