Barcode.IsDataValid

Barcode

bool TECIT.TBarCode.Barcode.IsDataValid(out Exception ex)

Determines whether the barcode data is valid for the chosen barcode type.

Parameters

Parameter / typeDescription
ex out Exception

The exception object which would be thrown by Draw() and other methods. This object contains detailed error information if the data is invalid; otherwise it is null.

Returns

true if the barcode data is valid; otherwise, false.

The following example casts the exception into a BarcodeException in order to retrieve more detailled error information. See also BarcodeErrors.

if (!barcode.IsDataValid(out Exception ex))
{
  if (ex is BarcodeException)
  {
    BarcodeException barcodeException = ex as BarcodeException;
    string error = barcodeException.DetailedMessage;
    if (barcodeException.ErrorCode == TECIT.TBarCode.BarcodeErrors.ErrorInvalidData)
    {
      int invalidDataPos = barcodeException.InvalidDataPosition;
      string invalidChar = (invalidDataPos >= 0) ? barcode.Data.Substring(invalidDataPos, 1) : String.Empty;
    }
  }
}

Search documentation

Search in
More scopes
Additional scopes

All contents