BPS C++ API  2.24.4
BpsFieldValidator Class Reference

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

#include <bpsfieldvalidator.h>

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. More...
 
bool checkInsert (const QVariantMap &aValues)
 Checks if the record data is valid for insertion. More...
 
bool checkUpdate (const QVariantMap &aValues)
 Checks if the record data is valid for update. More...
 
QString lastColumn () const
 
Status lastStatus () const
 
virtual QString message (Status aStatus)
 Get standard message for a status. More...
 

Detailed Description

This class implements the BPS table field validator.

Member Enumeration Documentation

◆ Status

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 

Numeric value is not positive.

StatusUnknown 

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

Constructor & Destructor Documentation

◆ BpsFieldValidator()

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

Member Function Documentation

◆ checkDelete()

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.

◆ checkInsert()

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.

◆ checkUpdate()

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.

◆ lastColumn()

QString BpsFieldValidator::lastColumn ( ) const
Returns
Column on which the the last error occurred. Empty in case last check passed.

◆ lastStatus()

Status BpsFieldValidator::lastStatus ( ) const
Returns
The last status set by the recent check method.

◆ message()

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: