MantisBase v0.4.9
Loading...
Searching...
No Matches
mb::MbValidators Class Reference

Static validators for schema definitions and CRUD request bodies. More...

#include <validators.h>

Static Public Member Functions

static std::optional< json > findPreset (const std::string &key)
static std::optional< std::string > validatePreset (const std::string &key, const std::string &value)
static std::optional< std::string > minimumConstraintCheck (const json &field, const json &body)
static std::optional< std::string > maximumConstraintCheck (const json &field, const json &body)
static std::optional< std::string > intPrecisionValueCheck (const json &field, const json &body)
static std::optional< std::string > requiredConstraintCheck (const json &field, const json &body)
static std::optional< std::string > validatorConstraintCheck (const json &field, const json &body)
static std::optional< std::string > foreignKeyConstraintCheck (const MantisBase &app, const json &field, const json &body)
 Validate a foreign-key field against a referenced entity record.
static std::optional< std::string > viewTypeSQLCheck (const json &body)
static std::optional< std::string > validateTableSchema (const json &entity_schema)
static std::optional< std::string > validateRequestBody (const MbEntity &entity, const json &body)
static std::optional< std::string > validateUpdateRequestBody (const MbEntity &entity, const json &body)

Detailed Description

Static validators for schema definitions and CRUD request bodies.

Each check returns std::nullopt on success or an error message string.

Member Function Documentation

◆ findPreset()

std::optional< json > mb::MbValidators::findPreset ( const std::string & key)
static

Look up a built-in validator preset definition by key.

◆ foreignKeyConstraintCheck()

std::optional< std::string > mb::MbValidators::foreignKeyConstraintCheck ( const MantisBase & app,
const json & field,
const json & body )
static

Validate a foreign-key field against a referenced entity record.

Requires a MantisBase reference so the check can load the target entity through app.entity(...) instead of a global accessor.

◆ intPrecisionValueCheck()

std::optional< std::string > mb::MbValidators::intPrecisionValueCheck ( const json & field,
const json & body )
static

Enforce int precision and range for int-typed fields.

◆ maximumConstraintCheck()

std::optional< std::string > mb::MbValidators::maximumConstraintCheck ( const json & field,
const json & body )
static

Enforce optional max constraint on numeric/string fields.

◆ minimumConstraintCheck()

std::optional< std::string > mb::MbValidators::minimumConstraintCheck ( const json & field,
const json & body )
static

Enforce optional min constraint on numeric/string fields.

◆ requiredConstraintCheck()

std::optional< std::string > mb::MbValidators::requiredConstraintCheck ( const json & field,
const json & body )
static

Enforce required when the field is marked required in the schema.

◆ validatePreset()

std::optional< std::string > mb::MbValidators::validatePreset ( const std::string & key,
const std::string & value )
static

Validate a value against a named preset (email, url, etc.).

◆ validateRequestBody()

std::optional< std::string > mb::MbValidators::validateRequestBody ( const MbEntity & entity,
const json & body )
static

Validate a create (POST) body against an entity schema.

◆ validateTableSchema()

std::optional< std::string > mb::MbValidators::validateTableSchema ( const json & entity_schema)
static

Validate a full entity schema JSON before create/update.

◆ validateUpdateRequestBody()

std::optional< std::string > mb::MbValidators::validateUpdateRequestBody ( const MbEntity & entity,
const json & body )
static

Validate a partial update (PATCH) body against an entity schema.

◆ validatorConstraintCheck()

std::optional< std::string > mb::MbValidators::validatorConstraintCheck ( const json & field,
const json & body )
static

Run custom validator preset named in the field constraints.

◆ viewTypeSQLCheck()

std::optional< std::string > mb::MbValidators::viewTypeSQLCheck ( const json & body)
static

Validate viewQuery SQL for view-type entity schemas.


The documentation for this class was generated from the following files:
  • /home/runner/work/mantisbase/mantisbase/include/mantisbase/core/models/validators.h
  • /home/runner/work/mantisbase/mantisbase/src/core/models/validators.cpp