Page MenuHomePhabricator

Apply default values from the schema if not set
Open, In Progress, MediumPublic

Description

Follow up from T362108: Implement JSON schema validation in ArrayDef

validate() supports a third parameter that sounds like it would help with our use case. It's a bit field with flags than can be combined. Here are a few that sound useful:

Constraint::CHECK_MODE_TYPE_CAST Enable fuzzy type checking for associative arrays and objects
Constraint::CHECK_MODE_APPLY_DEFAULTS Apply default values from the schema if not set

**CHECK_MODE_TYPE_CAST is already implemented

Related Objects

Event Timeline

Atieno changed the task status from Open to In Progress.Thu, Jun 13, 2:59 PM

It appears not to be possible to add multiple check modes to validator->validate()

Validating multiple times with different check modes also doesn't work since CHECK_MODE_APPLY_DEFAULTS requires the CHECK_MODE_TYPE_CAST to have been applied otherwise it brings the initial errors we were getting that required the check mode

Change #1050404 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] arrayDef: Apply default values from the schema if not set

https://gerrit.wikimedia.org/r/1050404