From 89adbe88b24526409a53a9e0e8f4a61d706bdced Mon Sep 17 00:00:00 2001 From: Fabian Mieller Date: Wed, 15 Feb 2023 18:59:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20added=20example=20for=20validati?= =?UTF-8?q?on=20custom=20attributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3b55e7e..6e32c69 100644 --- a/readme.md +++ b/readme.md @@ -40,10 +40,10 @@ Add the trait use acidjazz\metapi\MetApi; class Controller { - use Metapi; + use Metapi; ``` -## Examples +## Examples ```php option('contact.email', 'required|email', [], 'Email Address') + ->option('contact.name', 'required|string', [], 'Firstname') + ->option('contact.surname', 'required|string', [], 'Lastname') + ->verify(); + ... + $this->render($results); + } +``` + +`POST /send` + +```json +{ + "status": "error", + "errors": [ + { + "status": 400, + "message": "contact.email", + "detail": "Email Address is a required field." + }, + { + "status": 400, + "message": "contact.name", + "detail": "Firstname is a required field." + }, + { + "status": 400, + "message": "contact.surname", + "detail": "Lastname is a required field." + } + ] +} +```