1 /** 2 * Skadi.d Web Framework 3 * Validation Component 4 5 * Authors: Faianca 6 * Copyright: Copyright (c) 2015 Faianca 7 * License: MIT License, see LICENSE 8 */ 9 module skadi.components.validation.message; 10 11 import skadi.components.validation.messageinterface; 12 13 class Message : MessageInterface 14 { 15 16 protected: 17 18 string _type; 19 string _message; 20 string _field; 21 22 public: 23 /** 24 * @param string message 25 * @param string field 26 * @param string type 27 */ 28 this(string message, string field = null, string type = null) 29 { 30 this._message = message, 31 this._field = field, 32 this._type = type; 33 } 34 35 /** 36 * Sets message type 37 */ 38 Message setType(string type) 39 { 40 this._type = type; 41 return this; 42 } 43 44 /** 45 * Returns message type 46 */ 47 string getType() 48 { 49 return this._type; 50 } 51 52 /** 53 * Sets verbose message 54 */ 55 Message setMessage(string message) 56 { 57 this._message = message; 58 return this; 59 } 60 61 /** 62 * Returns verbose message 63 */ 64 string getMessage() 65 { 66 return this._message; 67 } 68 69 /** 70 * Sets field name related to message 71 */ 72 Message setField(string field) 73 { 74 this._field = field; 75 return this; 76 } 77 78 /** 79 * Returns field name related to message 80 * 81 * @return string 82 */ 83 string getField() 84 { 85 return this._field; 86 } 87 88 /** 89 * Magic toString method returns verbose message 90 */ 91 override string toString() 92 { 93 return this._message; 94 } 95 96 }