@@ -23,6 +23,7 @@ import {
2323import { PagerDutyActionParams , PagerDutyActionConnector } from './types' ;
2424import pagerDutySvg from './pagerduty.svg' ;
2525import { AddMessageVariables } from '../add_message_variables' ;
26+ import { hasMustacheTokens } from '../../lib/has_mustache_tokens' ;
2627
2728export function getActionType ( ) : ActionTypeModel {
2829 return {
@@ -62,6 +63,7 @@ export function getActionType(): ActionTypeModel {
6263 const validationResult = { errors : { } } ;
6364 const errors = {
6465 summary : new Array < string > ( ) ,
66+ timestamp : new Array < string > ( ) ,
6567 } ;
6668 validationResult . errors = errors ;
6769 if ( ! actionParams . summary ?. length ) {
@@ -74,6 +76,21 @@ export function getActionType(): ActionTypeModel {
7476 )
7577 ) ;
7678 }
79+ if ( actionParams . timestamp && ! hasMustacheTokens ( actionParams . timestamp ) ) {
80+ if ( isNaN ( Date . parse ( actionParams . timestamp ) ) ) {
81+ errors . timestamp . push (
82+ i18n . translate (
83+ 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.error.invalidTimestamp' ,
84+ {
85+ defaultMessage : 'Timestamp must be formatted as a date, such as {now}.' ,
86+ values : {
87+ now : new Date ( ) . toISOString ( ) ,
88+ } ,
89+ }
90+ )
91+ ) ;
92+ }
93+ }
7794 return validationResult ;
7895 } ,
7996 actionConnectorFields : PagerDutyActionConnectorFields ,
@@ -334,6 +351,8 @@ const PagerDutyParamsFields: React.FunctionComponent<ActionParamsProps<PagerDuty
334351 < EuiFlexItem >
335352 < EuiFormRow
336353 fullWidth
354+ error = { errors . timestamp }
355+ isInvalid = { errors . timestamp . length > 0 && timestamp !== undefined }
337356 label = { i18n . translate (
338357 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.timestampTextFieldLabel' ,
339358 {
@@ -355,8 +374,9 @@ const PagerDutyParamsFields: React.FunctionComponent<ActionParamsProps<PagerDuty
355374 name = "timestamp"
356375 data-test-subj = "timestampInput"
357376 value = { timestamp || '' }
377+ isInvalid = { errors . timestamp . length > 0 && timestamp !== undefined }
358378 onChange = { ( e : React . ChangeEvent < HTMLInputElement > ) => {
359- editAction ( 'timestamp' , e . target . value , index ) ;
379+ editAction ( 'timestamp' , e . target . value . trim ( ) , index ) ;
360380 } }
361381 onBlur = { ( ) => {
362382 if ( timestamp ?. trim ( ) ) {
0 commit comments