Fails if the string does not have the given length.
771217
public void hasLength(int expectedLength) {
    checkArgument(expectedLength >= 0, "expectedLength(%s) must be >= 0", expectedLength);
    check("length()").that(actual().length()).isEqualTo(expectedLength);
  }
43088
public function isValidStringLength($str, $min = null, $max = null): bool
    {
        $len = mb_strlen($str, 'UTF-8');

        return (($min !== null) && ($len >= $min)) || (($max !== null) && ($len <= $max));
    }
258118
private function __validateString($string, $minLength = 1, $maxLength = 0)
    {
        if (!is_string($string)) {
            $this->error = 'parameter is not string.';
            return false;
        } else if ($maxLength > 0 && strlen($string) > $maxLength) {
            $this->error = 'parameter is too long. string:' . $string;
            return false;
        } else if (strlen($string) < $minLength) {
            $this->error = 'parameter is too short. string:' . $string;
            return false;
        }
        return true;
    }
1221667
public void setLength(int length) {
		if (length < 0 || body.length == length) {
			return;
		}

		int oldPos = pos;
		pos = Math.min(pos, length);

		byte[] newBody = new byte[length];
		System.arraycopy(body, 0, newBody, 0, pos);
		body = newBody;
		
		if (oldPos > pos) {
			cachedString = null;
		}
	}
902719
public static boolean isEmpty(String str) {
        if (str == null)
            return true;
        if ("".equals(str.trim()))
            return true;
        return str.isEmpty();
    }
1117633
def read_string(self, size):
        
        if size < 0:
            raise errors.DecodeError('Negative size %d' % size)
        s = self._input.read(size)
        if len(s) != size:
            raise errors.DecodeError('String claims to have %d bytes, but read %d' % (size, len(s)))
        self._pos += len(s)  # Only advance by the number of bytes actually read.
        return s
751764
def _check_len(a, b):
    
    if len(a) != len(b):
        msg = "Length must be {}. Got {}".format(len(a), len(b))
        raise ValueError(msg)
884047
protected void assertNotNullOrEmpty(String value, String message) throws IllegalArgumentException {
        if (value == null || value.length() == 0) {
            throw new IllegalArgumentException(message);
        }
    }
301893
static boolean isOctetStringValid(String value, int maxLength) {
        if (value == null)
            return true;
        if (value.length() > maxLength)
            return false;
        return true;
    }
341811
def Length(min=None, max=None, min_message="Must have a length of at least {min}", max_message="Must have a length of at most {max}"):
    
    validator = Range(min, max, min_message, max_message)
    @wraps(Length)
    def built(value):
        if not hasattr(value, '__len__'):
            raise Error("Does not have a length")
        validator(len(value))
        return value
    return built
627554
private String limitStringLength(String str) {
    if (str.length() > MAX_STRING_LENGTH) {
      str = str.substring(0, MAX_STRING_LENGTH) + " ..."; 
    }
    return str;
  }
682140
public static void checkNotNullOrEmpty(String string, String message) {
    if (string == null || string.isEmpty()) {
      throw new IllegalArgumentException(message);
    }
  }
137137
public static String requireNotEmpty(final String str) throws NullPointerException, IllegalArgumentException {
	if (str.length() == 0) {
	    throw new IllegalArgumentException();
	}
	return str;
    }
1253758
static boolean isCOctetStringValid(String value, int maxLength) {
        if (value == null)
            return true;
        if (value.length() >= maxLength)
            return false;
        return true;

    }
1172146
private Node tryFoldStringCharCodeAt(Node n, Node stringNode, Node arg1) {
    checkArgument(n.isCall());
    checkArgument(stringNode.isString());

    int index;
    String stringAsString = stringNode.getString();

    if (arg1 != null && arg1.isNumber()
        && arg1.getNext() == null) {
      index = (int) arg1.getDouble();
    } else {
      return n;
    }

    if (index < 0 || stringAsString.length() <= index) {
      // http://es5.github.com/#x15.5.4.5 says NaN is returned when index is
      // out of bounds but we bail.
      return n;
    }

    Node resultNode = IR.number(stringAsString.charAt(index));
    Node parent = n.getParent();
    parent.replaceChild(n, resultNode);
    reportChangeToEnclosingScope(parent);
    return resultNode;
  }
468471
public static boolean isEmpty(Object value) throws IOException {
		if(value instanceof String) {
			// If A is a string, then the result is A.
			return ((String)value).isEmpty();
		} else if(value == null) {
			// Otherwise, if A is null, then the result is "".
			return true;
		} else if(value instanceof Writable) {
			return ((Writable)value).getLength() == 0;
		} else if(value instanceof Node) {
			// Otherwise, if is a DOM node, serialize the output
			return false; // There is a node, is not empty
		} else {
			// Otherwise, if A.toString() throws an exception, then raise an error
			// Otherwise, the result is A.toString();
			return value.toString().isEmpty();
		}
	}
876286
function STRING(length) {
    length = length || 255;
    if (!(this instanceof STRING)) {
        return new STRING(length);
    }
    this.length = length;
    this.sql = 'VARCHAR(' + length + ')';
}