drogonframework / drogonframework/drogon

Custom model ORM validation

Open
#759 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

Is there any way to make custom validation on ORM object before save entity?

example:
```

auto dbClientPtr = drogon::app().getDbClient();
Mapper mp(dbClientPtr);

Json::Value json;
json["username"] = username;
json["email"] = email;

drogon_model::PROJECTNAME::Users user(json);

mp.insert(user);
```

model is auto generated by drogon_ctl, so we cant edit the model. What we can do to not include validation code in controller every time when we save entity by mp.insert, mp.update etc

if i wrap code with try catch i will se DB errors from DrogonDbException.

Is there way to make custom Exception, so custom Validation to run custom Exception?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.