@@ -6,7 +6,8 @@ const getSecret = require('../get-secret');
66const { templates } = require ( '../templates' ) ;
77const Boom = require ( '@hapi/boom' ) ;
88const Joi = require ( 'joi' ) ;
9- const { failAction } = require ( '../tools' ) ;
9+ const { failAction, validationHelper } = require ( '../tools' ) ;
10+ const { joiLocales } = require ( '../translations' ) ;
1011
1112const { templateSchemas, accountIdSchema } = require ( '../schemas' ) ;
1213
@@ -76,33 +77,36 @@ async function init(args) {
7677 } ,
7778 failAction,
7879
79- payload : Joi . object ( {
80- account : Joi . string ( )
81- . empty ( '' )
82- . trim ( )
83- . allow ( null )
84- . max ( 256 )
85- . example ( 'example' )
86- . description ( 'Account ID. Use `null` for public templates.' )
87- . required ( ) ,
88-
89- name : Joi . string ( ) . max ( 256 ) . example ( 'Transaction receipt' ) . description ( 'Name of the template' ) . label ( 'TemplateName' ) . required ( ) ,
90- description : Joi . string ( )
91- . allow ( '' )
92- . max ( 1024 )
93- . example ( 'Something about the template' )
94- . description ( 'Optional description of the template' )
95- . label ( 'TemplateDescription' ) ,
96- format : Joi . string ( ) . valid ( 'html' , 'markdown' ) . default ( 'html' ) . description ( 'Markup language for HTML ("html" or "markdown")' ) ,
97- content : Joi . object ( {
98- subject : templateSchemas . subject ,
99- text : templateSchemas . text ,
100- html : templateSchemas . html ,
101- previewText : templateSchemas . previewText
102- } )
103- . required ( )
104- . label ( 'CreateTemplateContent' )
105- } ) . label ( 'CreateTemplate' )
80+ payload : validationHelper (
81+ joiLocales ,
82+ Joi . object ( {
83+ account : Joi . string ( )
84+ . empty ( '' )
85+ . trim ( )
86+ . allow ( null )
87+ . max ( 256 )
88+ . example ( 'example' )
89+ . description ( 'Account ID. Use `null` for public templates.' )
90+ . required ( ) ,
91+
92+ name : Joi . string ( ) . max ( 256 ) . example ( 'Transaction receipt' ) . description ( 'Name of the template' ) . label ( 'TemplateName' ) . required ( ) ,
93+ description : Joi . string ( )
94+ . allow ( '' )
95+ . max ( 1024 )
96+ . example ( 'Something about the template' )
97+ . description ( 'Optional description of the template' )
98+ . label ( 'TemplateDescription' ) ,
99+ format : Joi . string ( ) . valid ( 'html' , 'markdown' ) . default ( 'html' ) . description ( 'Markup language for HTML ("html" or "markdown")' ) ,
100+ content : Joi . object ( {
101+ subject : templateSchemas . subject ,
102+ text : templateSchemas . text ,
103+ html : templateSchemas . html ,
104+ previewText : templateSchemas . previewText
105+ } )
106+ . required ( )
107+ . label ( 'CreateTemplateContent' )
108+ } ) . label ( 'CreateTemplate' )
109+ )
106110 } ,
107111
108112 response : {
@@ -168,22 +172,25 @@ async function init(args) {
168172 template : Joi . string ( ) . max ( 256 ) . required ( ) . example ( 'example' ) . description ( 'Template ID' )
169173 } ) . label ( 'GetTemplateRequest' ) ,
170174
171- payload : Joi . object ( {
172- name : Joi . string ( ) . empty ( '' ) . max ( 256 ) . example ( 'Transaction receipt' ) . description ( 'Name of the template' ) . label ( 'TemplateName' ) ,
173- description : Joi . string ( )
174- . allow ( '' )
175- . max ( 1024 )
176- . example ( 'Something about the template' )
177- . description ( 'Optional description of the template' )
178- . label ( 'TemplateDescription' ) ,
179- format : Joi . string ( ) . empty ( '' ) . valid ( 'html' , 'markdown' ) . default ( 'html' ) . description ( 'Markup language for HTML ("html" or "markdown")' ) ,
180- content : Joi . object ( {
181- subject : templateSchemas . subject ,
182- text : templateSchemas . text ,
183- html : templateSchemas . html ,
184- previewText : templateSchemas . previewText
185- } ) . label ( 'UpdateTemplateContent' )
186- } ) . label ( 'UpdateTemplate' )
175+ payload : validationHelper (
176+ joiLocales ,
177+ Joi . object ( {
178+ name : Joi . string ( ) . empty ( '' ) . max ( 256 ) . example ( 'Transaction receipt' ) . description ( 'Name of the template' ) . label ( 'TemplateName' ) ,
179+ description : Joi . string ( )
180+ . allow ( '' )
181+ . max ( 1024 )
182+ . example ( 'Something about the template' )
183+ . description ( 'Optional description of the template' )
184+ . label ( 'TemplateDescription' ) ,
185+ format : Joi . string ( ) . empty ( '' ) . valid ( 'html' , 'markdown' ) . default ( 'html' ) . description ( 'Markup language for HTML ("html" or "markdown")' ) ,
186+ content : Joi . object ( {
187+ subject : templateSchemas . subject ,
188+ text : templateSchemas . text ,
189+ html : templateSchemas . html ,
190+ previewText : templateSchemas . previewText
191+ } ) . label ( 'UpdateTemplateContent' )
192+ } ) . label ( 'UpdateTemplate' )
193+ )
187194 } ,
188195
189196 response : {
0 commit comments