From 156d51592505314c8df3afd1cb5a87c61bae54fd Mon Sep 17 00:00:00 2001 From: Maks3w Date: Mon, 20 Jul 2015 21:06:32 +0200 Subject: [PATCH 1/4] Validator result interface proposal --- src/ResultInterface.php | 41 +++++++++++++++++ .../TranslatableMessageInterface.php | 46 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/ResultInterface.php create mode 100644 src/Translator/TranslatableMessageInterface.php diff --git a/src/ResultInterface.php b/src/ResultInterface.php new file mode 100644 index 000000000..e64e19d59 --- /dev/null +++ b/src/ResultInterface.php @@ -0,0 +1,41 @@ + Date: Mon, 20 Jul 2015 21:15:21 +0200 Subject: [PATCH 2/4] [result] Add isNotValid method While this method does not apport new features it improves the expressiveness. credits @gianarb https://github.com/zendframework/zend-validator/pull/23 --- src/ResultInterface.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ResultInterface.php b/src/ResultInterface.php index e64e19d59..b5fc0cb54 100644 --- a/src/ResultInterface.php +++ b/src/ResultInterface.php @@ -13,7 +13,7 @@ * This interface provide methods for to know the result of a validation and the reasons when the result is not valid * * This interface resolve the following questions: - * - Is the result valid? + * - Is the result valid or invalid? * - If not, Why is not valid? */ interface ResultInterface @@ -25,6 +25,13 @@ interface ResultInterface */ public function isValid(); + /** + * Is the validation result invalid? + * + * @return bool + */ + public function isNotValid(); + /** * Returns the list of error violations in a machine readable format. * From 2b28ea1ef181fd3be893af5a75f82cdeb5ec4a66 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Sun, 20 Dec 2015 19:07:08 +0100 Subject: [PATCH 3/4] Allow TranslatableMessageInterface::__toString() to be translated --- src/ResultInterface.php | 2 +- src/Translator/TranslatableMessageInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ResultInterface.php b/src/ResultInterface.php index b5fc0cb54..8f96695df 100644 --- a/src/ResultInterface.php +++ b/src/ResultInterface.php @@ -40,7 +40,7 @@ public function isNotValid(); public function getErrorCodes(); /** - * Get the error messages (with the variables replaced) associated with the validation result + * Get the error messages associated with the validation result * * @return Translator\TranslatableMessageInterface[] */ diff --git a/src/Translator/TranslatableMessageInterface.php b/src/Translator/TranslatableMessageInterface.php index 5013fdc12..6af55a952 100644 --- a/src/Translator/TranslatableMessageInterface.php +++ b/src/Translator/TranslatableMessageInterface.php @@ -38,7 +38,7 @@ public function getMessageVariables(); public function getTranslationDomain(); /** - * Returns the message without translation and with the placeholders replaced by the variables. + * Returns the message template with the placeholders replaced by the variables. * * @return string */ From 96c9d3a9950f43130889e07d08e6047524c416e0 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Sun, 20 Dec 2015 19:07:38 +0100 Subject: [PATCH 4/4] Detail how is supposed to be used TranslatableMessageInterface --- src/Translator/TranslatableMessageInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Translator/TranslatableMessageInterface.php b/src/Translator/TranslatableMessageInterface.php index 6af55a952..e735d829a 100644 --- a/src/Translator/TranslatableMessageInterface.php +++ b/src/Translator/TranslatableMessageInterface.php @@ -11,6 +11,8 @@ /** * This interface provide methods for extract the translatable parts of a message. + * + * The translatable parts of a message are those parts allow to consumption by ICU message formatters. */ interface TranslatableMessageInterface {