mttValidateName.m 801 B

12345678910111213141516171819
  1. function mttValidateName(name)
  2. mttAssert(~isempty(name),'Empty name') ;
  3. numbers = (name>=48 & name<=57) ;
  4. letters = (name>=65 & name<=90)|(name>=97 & name<=122) ;
  5. underscores = (name==95) ;
  6. is_alphanumeric = all(numbers|letters|underscores) ;
  7. starts_with_letter = isletter(name(1)) ;
  8. valid_name = is_alphanumeric & starts_with_letter ;
  9. % mtt_prefix = strncmp(name,'mtt_',4) ;
  10. mtt_delimiter = ~isempty(findstr(name,'__')) ;
  11. % mttAssert(~mtt_prefix,['"',name,'" must not contain "mtt_" prefix']) ;
  12. mttAssert(~mtt_delimiter,['"',name,'" must not contain contiguous "_" delimiters']) ;
  13. mttAssert(valid_name,['"',name,'" is not a valid name']) ;
  14. mttAssert(length(name)<32,['"',name,'" must be shortened to less than 32 characters']) ;