@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
14 lines (13 loc) • 474 B
JavaScript
import { JsonEntityFn } from "./jsonEntityFn.js";
/**
* Add an error message to the property.
* @decorator
* @ajv
*/
export function ErrorMsg(obj) {
return JsonEntityFn((store) => {
// since errorMessage is a custom key, it is prefixed with a # to avoid conflict with JSON Schema keywords
const errorMessage = store.parentSchema.get("#errorMessage") || {};
store.parentSchema.customKey("errorMessage", { ...errorMessage, ...obj });
});
}