Method: RbNaCl::Util.check_string_validation
- Defined in:
- lib/rbnacl/util.rb
.check_string_validation(string) ⇒ Object
Check a passed string is it valid
Raise an error if passed argument is invalid
163 164 165 166 167 168 169 |
# File 'lib/rbnacl/util.rb', line 163 def check_string_validation(string) raise TypeError, "can't convert #{string.class} into String with #to_str" unless string.respond_to? :to_str string = string.to_str raise EncodingError, "strings must use BINARY encoding (got #{string.encoding})" if string.encoding != Encoding::BINARY end |