diff --git a/module/Olcs/src/Form/Model/Fieldset/Message/CreateInput.php b/module/Olcs/src/Form/Model/Fieldset/Message/CreateInput.php index 8552374dc..a084b9c05 100644 --- a/module/Olcs/src/Form/Model/Fieldset/Message/CreateInput.php +++ b/module/Olcs/src/Form/Model/Fieldset/Message/CreateInput.php @@ -10,6 +10,7 @@ use Laminas\Form\Annotation as Form; use Laminas\Form\Element\Textarea; use Laminas\Validator\StringLength; +use Laminas\Validator\NotEmpty; use Olcs\Service\Data\MessagingAppOrLicNo; class CreateInput @@ -25,7 +26,13 @@ class CreateInput * "class": "govuk-select" * }) * @Form\Type(DynamicSelect::class) - * @Form\Required(true) + * @Form\Validator(NotEmpty::class, + * options={ + * "messages":{NotEmpty::IS_EMPTY:"messaging.form.message.subject.empty.error_message"}, + * }, + * breakChainOnFailure=true, + * priority=100, + * ) */ public ?DynamicSelect $messageSubject = null; @@ -41,7 +48,13 @@ class CreateInput * "class": "govuk-select" * }) * @Form\Type(DynamicSelect::class) - * @Form\Required(true) + * * @Form\Validator(NotEmpty::class, + * options={ + * "messages":{NotEmpty::IS_EMPTY:"messaging.form.message.app_or_lic_no.empty.error_message"}, + * }, + * breakChainOnFailure=true, + * priority=100, + * ) */ public ?DynamicSelect $appOrLicNo = null; @@ -57,7 +70,24 @@ class CreateInput * @Form\Required(true) * @Form\Type(Textarea::class) * @Form\Filter(StringTrim::class) - * @Form\Validator(StringLength::class, options={"min": 5, "max": 1000}) + * @Form\Validator(NotEmpty::class, + * options={ + * "messages": { + * NotEmpty::IS_EMPTY: "messaging.form.message.content.empty.error_message" + * }, + * }, + * breakChainOnFailure=true + * ) + * @Form\Validator(StringLength::class, + * options={ + * "min": 5, + * "max": 1000, + * "messages": { + * StringLength::TOO_SHORT:"messaging.form.message.content.too_short.error_message", + * StringLength::TOO_LONG:"messaging.form.message.content.too_long.error_message", + * } + * } + * ) */ public ?Textarea $messageContent = null; } diff --git a/module/Olcs/src/Form/Model/Fieldset/Message/ReplyInput.php b/module/Olcs/src/Form/Model/Fieldset/Message/ReplyInput.php index a911cfa89..5a7c07bb6 100644 --- a/module/Olcs/src/Form/Model/Fieldset/Message/ReplyInput.php +++ b/module/Olcs/src/Form/Model/Fieldset/Message/ReplyInput.php @@ -8,6 +8,7 @@ use Laminas\Form\Annotation as Form; use Laminas\Form\Element\Textarea; use Laminas\Validator\StringLength; +use Laminas\Validator\NotEmpty; class ReplyInput { @@ -23,7 +24,22 @@ class ReplyInput * @Form\Required(true) * @Form\Type(Textarea::class) * @Form\Filter(StringTrim::class) - * @Form\Validator(StringLength::class, options={"min": 5, "max": 1000}) + * @Form\Validator(NotEmpty::class, + * options={ + * "messages":{NotEmpty::IS_EMPTY: "messaging.form.message.content.empty.error_message"}, + * }, + * breakChainOnFailure=true + * ) + * @Form\Validator(StringLength::class, + * options={ + * "min": 5, + * "max": 1000, + * "messages": { + * StringLength::TOO_SHORT: "messaging.form.message.content.too_short.error_message", + * StringLength::TOO_LONG: "messaging.form.message.content.too_long.error_message", + * } + * } + * ) */ public ?TextArea $reply = null; }