Class CASNumberValidator

java.lang.Object
org.apache.commons.validator.routines.CASNumberValidator
All Implemented Interfaces:
Serializable

public final class CASNumberValidator extends Object implements Serializable
CAS Registry Number (or Chemical Abstracts Service (CAS RN)) validation.

CAS Numbers are unique identification numbers used to identify chemical substance described in the open scientific literature.

Check digit calculation is based on modulus 10 with digits being weighted based on their position (from right to left).

For further information see Wikipedia - CAS Registry Number.

Since:
1.9.0
See Also:
  • Method Details

    • getInstance

      public static CASNumberValidator getInstance()
      Gets the singleton instance of this validator.
      Returns:
      A singleton instance of the CAS Number validator.
    • isValid

      public boolean isValid(String code)
      Tests whether the code is a valid CAS number.
      Parameters:
      code - The code to validate.
      Returns:
      true if a CAS number, otherwise false.
    • validate

      public Object validate(String code)
      Checks the code is valid CAS number.
      Parameters:
      code - The code to validate.
      Returns:
      A CAS number code with dashes removed if valid, otherwise null.