Nette/Schema skipDefaults() unclarity

Generous Backer | 255

From documentation:

If you do not want to output properties with only a default value, use skipDefaults():

$schema = Expect::structure([
	'required' => Expect::string()->required(),
	'optional' => Expect::string(),

$processor->process($schema, ['required' => 'foo']);
// OK, returns {'required' => 'foo'}

But there is no default values in the example, so what is it skipping?

Also, could you please provide more complex example? How about combination required() and default()? It seems that when it is required, it throws error, because it does not fill the default value, because it is skipped? Or is also the validation skipped, so it does not return any error?

Or can I understand it like if I use skipDefaults(), it is the same as I would remove all default(...) from the structure?


@Felix @DavidGrudl

David Grudl
Nette Core | 8182

Important sentence is “By default, all properties are optional and have a default value of null”, so there are implicit default values.