Validators
Field Validators
export class EntComment extends BaseEnt(cluster, schema) {
static override configure() {
return new this.Configuration({
privacyLoad: [...],
privacyInsert: [...],
validators: [
new FieldIs(
"message",
(value, _row, _vc) => value.trim().length > 0,
"Please provide comment text",
),
new FieldIs(
"topic_id",
async (value, _row, vc) => {
const topic = await EntTopic.loadX(vc, value);
return Date.now() - topic.created_at.getTime() < 1000 * 3600 * 24;
},
"You can only leave comments on topics created today",
),
...
]
});
}
}Whole-Row Validators
Using with Zod or Standard Schema
Running Validators Manually
Last updated