-
Notifications
You must be signed in to change notification settings - Fork 11
Validation
高新成 edited this page Nov 20, 2018
·
3 revisions
@Table("UserInfo")
class UserInfo : Model {
mixin MakeModel;
@AutoIncrement @PrimaryKey
int id;
@Length(0,50,"length must be between 0 and 50")
string nickName;
@Max(150)
int age;
}
auto query = em.createQuery!UserInfo("select u from UserInfo u");
auto uinfos = query.getResultList();
foreach(u;uinfos)
{
auto result = u.valid();
if (result.isValid() == false)
{
import std.stdio : writeln;
foreach(key, message; result.messages())
{
writeln("%s: %s", key, message);
}
}
}