It would be useful if required() method had fingerprint like this:
public function required(bool $required = true): self
Imagine you want to generate the schema programmatically either to require all options or to allow for only partial result. Imagine some create operation versus update operation where either I have to provide all fields or only ones I want to edit.
public static function getSchema(bool $partialAllowed) {
return Expect::structure(
[
'name' => Expect::string()->required(!$partialAllowed),
]
);
}
I am implementing restfull api, particularly post, put and patch methods and this would hugely declutter my code.
It would be useful if
required()
method had fingerprint like this:public function required(bool $required = true): self
Imagine you want to generate the schema programmatically either to require all options or to allow for only partial result. Imagine some create operation versus update operation where either I have to provide all fields or only ones I want to edit.
I am implementing restfull api, particularly post, put and patch methods and this would hugely declutter my code.
I will send PR shortly.