code: public static boolean isValid(String casNumber) {
          boolean overall = true;
          /*
           * check format
           */
          String format = "^(\\d+)-(\\d\\d)-(\\d)$";
          Pattern pattern = Pattern.compile(format);
          Matcher matcher = pattern.matcher(casNumber);
          overall = overall && matcher.matches();
  
          if (matcher.matches()) {
              /*
               * check number
               */
              String part1 = matcher.group(1);
              String part2 = matcher.group(2);
              String part3 = matcher.group(3);
              int part1value = Integer.parseInt(part1);
              if (part1value < 50) {
                  overall = false;
                  // CAS numbers start at 50-00-0
              } else {
                  int digit = CASNumber.calculateCheckDigit(part1, part2);
                  overall = overall && (digit == Integer.parseInt(part3));
              }
          }
  
          return overall;
      }
docs: Checks whether the registry number is valid.
  
  @param casNumber  the CAS number to validate
  @cdk.keyword CAS number
  @cdk.keyword validation
  @return true if a valid CAS number, false otherwise