Find nodes by string length

I want to find all the users with username length less than 4. What I’m doing wrong?

ERROR: Some variables are used but not defined Defined:[] Used:[username]

{
     userlen(func: lt(len(username), 4))
     {
    	user_id
    	username
  }
}

I tried something like this, but it return all the nodes (with names longer than 4):

{
  	users(func: has(username)) { un as username }	
  
     userlen(func: lt(len(un), 4))
     {
    	user_id
    	username
  }
}

This function len() isn’t a function to check the length of a value(string length). Is to check the length of a query block. The name is a bit confusing, but it is like that.

Yeah, that function requires a variable. You have put the predicate name instead.