# Decorator AfterDeserialize

Decorator schema property private
Module
import { AfterDeserialize } from "@tsed/json-mapper/src/decorators/afterDeserialize"
Source/packages/json-mapper/src/decorators/afterDeserialize.ts

# Overview

function AfterDeserialize(cb: AfterDeserializeCallback): ClassDecorator;

# Description

Call the function after JsonMapper.

# Example

@AfterDeserialize((data: Model) => { // After deserialize get the instance class
   if (data.prop1 === 'VALUE' && data.prop2 !== 'VALUE2') {
     throw BadRequest('MyMessage'); // or throw a ValidationError
   } else {
     data.prop2 = 'VALUE2';
     return data;
   }
})
class Model {
   @Property()
   prop1: string;
   @Property()
   prop2: string;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Other topics