[wp-trac] [WordPress Trac] #34893: Improve Customizer setting validation model
WordPress Trac
noreply at wordpress.org
Wed Dec 9 17:44:07 UTC 2015
#34893: Improve Customizer setting validation model
-------------------------------------+--------------------------
Reporter: westonruter | Owner: westonruter
Type: enhancement | Status: accepted
Priority: normal | Milestone: 4.5
Component: Customize | Version: 3.4
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: javascript
-------------------------------------+--------------------------
Comment (by westonruter):
Another improvement is needed on the JS side of things. Namely, the there
is currently a `wp.customize.Setting.prototype.validate()` method allows
you to sanitize a value and also to block the setting update if you pass
back `null` to block the `Setting` (really, the `Value`). So really, the
`validate` method in JS is serving in the same purpose as the `sanitize`
method in PHP. They both conflate sanitization and validation.
I suggest that we extend `wp.customize.Setting` to introduce a `sanitize`
method for the purpose of sanitization, and that the existing `validate`
method be extended to allow for the returning of an `Error` object, which
would have the same effect for blocking the value but it could also then
emit an event on the `Setting` object, which could then be picked up by
any controls to then display a validation error message.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34893#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list