File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ public function hasAny($keys = [])
159159 return false ;
160160 }
161161
162+ /**
163+ * Determine if messages don't exist for all of the given keys.
164+ *
165+ * @param array|string|null $key
166+ * @return bool
167+ */
168+ public function missing ($ key )
169+ {
170+ $ keys = is_array ($ key ) ? $ key : func_get_args ();
171+
172+ return ! $ this ->hasAny ($ keys );
173+ }
174+
162175 /**
163176 * Get the first message from the message bag for a given key.
164177 *
Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ public function testHasIndicatesExistence()
115115 $ this ->assertFalse ($ container ->has ('bar ' ));
116116 }
117117
118+ public function testMissingIndicatesNonExistence ()
119+ {
120+ $ container = new MessageBag ;
121+ $ container ->setFormat (':message ' );
122+ $ container ->add ('foo ' , 'bar ' );
123+ $ this ->assertFalse ($ container ->missing ('foo ' ));
124+ $ this ->assertFalse ($ container ->missing (['foo ' , 'baz ' ]));
125+ $ this ->assertFalse ($ container ->missing ('foo ' , 'baz ' ));
126+ $ this ->assertTrue ($ container ->missing ('baz ' ));
127+ $ this ->assertTrue ($ container ->missing (['baz ' , 'biz ' ]));
128+ $ this ->assertTrue ($ container ->missing ('baz ' , 'biz ' ));
129+ }
130+
118131 public function testAddIf ()
119132 {
120133 $ container = new MessageBag ;
You can’t perform that action at this time.
0 commit comments