Documents > BPS V2 C++ API
BpsFieldValidator Class Reference

This class implements the BPS table field validator. More...

#include <bpsfieldvalidator.h>

List of all members.

Public Types

enum  Status {
  StatusOK,
  StatusMissing,
  StatusInvalid,
  StatusDuplicate,
  StatusBadRef,
  StatusNotPositive,
  StatusUnknown
}
 Return status from check function. More...

Public Member Functions

 BpsFieldValidator (BpsDatastore *aDatastore, const QString &aTable)
bool checkDelete (const QVariantMap &aValues)
 Checks if the record data is valid to delete.
bool checkInsert (const QVariantMap &aValues)
 Checks if the record data is valid for insertion.
bool checkUpdate (const QVariantMap &aValues)
 Checks if the record data is valid for update.
QString lastColumn () const
Status lastStatus () const
virtual QString message (Status aStatus)
 Get standard message for a status.

Detailed Description

This class implements the BPS table field validator.


Member Enumeration Documentation

Return status from check function.

Enumerator:
StatusOK 

All checks passed ok.

StatusMissing 

Mandatory field but input missing.

StatusInvalid 

Input is invalid (too short, too long, wrong format or data).

StatusDuplicate 

Unique field, but same value found in other record.

StatusBadRef 

Key not found in referenced relation table.

StatusNotPositive 

Nubmeric value is not positive.

StatusUnknown 

Unknown status (mostly an application bug, not a regular value).


Constructor & Destructor Documentation

BpsFieldValidator::BpsFieldValidator ( BpsDatastore aDatastore,
const QString &  aTable 
)
Parameters:
aDatastoreThe datastore connection to use.
aTableThe name of the table to validate for.

Member Function Documentation

bool BpsFieldValidator::checkDelete ( const QVariantMap &  aValues)

Checks if the record data is valid to delete.

Stops on first fail and sets the values for lastStatus() and lastColumn().

Parameters:
aValuesList of column name / value pairs for the record to check.
Returns:
True if all column checks passed, false otherwise.
Exceptions:
BpsExceptionThrown when db access fails or validator is broken.
bool BpsFieldValidator::checkInsert ( const QVariantMap &  aValues)

Checks if the record data is valid for insertion.

Stops on first fail and sets the values for lastStatus() and lastColumn().

Parameters:
aValuesList of column name / value pairs for the record to check.
Returns:
True if all column checks passed, false otherwise.
Exceptions:
BpsExceptionThrown when db access fails or validator is broken.
bool BpsFieldValidator::checkUpdate ( const QVariantMap &  aValues)

Checks if the record data is valid for update.

Stops on first fail and sets the values for lastStatus() and lastColumn().

Parameters:
aValuesList of column name / value pairs for the record to check.
Returns:
True if all column checks passed, false otherwise.
Exceptions:
BpsExceptionThrown when db access fails or validator is broken.
QString BpsFieldValidator::lastColumn ( ) const
Returns:
Column on which the the last error occurred. Empty in case last check passed.
Status BpsFieldValidator::lastStatus ( ) const
Returns:
The last status set by the recent check method.
virtual QString BpsFieldValidator::message ( Status  aStatus) [virtual]

Get standard message for a status.

Parameters:
aStatusThe status to get the message for.
Returns:
Standard message for failure status. For StatusOK an empty string is returned.

The documentation for this class was generated from the following file: