API: Abstract out parameter validation
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 22 May 2018 23:23:20 +0000 (19:23 -0400)
committerGergő Tisza <tgr.huwiki@gmail.com>
Sun, 23 Jun 2019 08:58:44 +0000 (10:58 +0200)
commit002f409a0b0ba15264050cd1547ddf56b1a5d963
treed4323cf9eab1556b10abb9b73e56a87b893cce39
parenta8f302118184c543ff58e9a93c0cf03c84bf712a
API: Abstract out parameter validation

With the introduction of a REST API into MediaWiki core, we're going to
want to share parameter validation logic rather than having similar code
in both the Action API and the REST API. This abstracts out parameter
validation logic as a library.

There will be at least two follow-up patches:
* One to add calls in the REST API, plus the interface for the REST API
  to do body validation. Should be reasonably straightforward.
* One to adjust the Action API to use this. That'll be much less
  straightforward, as the Action API needs some MediaWiki-specific types
  (which the REST API might use too in the future) and needs to override
  the defaults on some of the library's checks (to maintain back-compat).

Bug: T142080
Bug: T223239
Change-Id: I5c0cc3a8d686ace97596df5832c450a6a50f902c
Depends-On: Iea05dc439688871c574c639e617765ae88a75ff7
37 files changed:
includes/AutoLoader.php
includes/libs/ParamValidator/Callbacks.php [new file with mode: 0644]
includes/libs/ParamValidator/ParamValidator.php [new file with mode: 0644]
includes/libs/ParamValidator/README.md [new file with mode: 0644]
includes/libs/ParamValidator/SimpleCallbacks.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/BooleanDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/EnumDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/FloatDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/IntegerDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/LimitDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/PasswordDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/PresenceBooleanDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/StringDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/TimestampDef.php [new file with mode: 0644]
includes/libs/ParamValidator/TypeDef/UploadDef.php [new file with mode: 0644]
includes/libs/ParamValidator/Util/UploadedFile.php [new file with mode: 0644]
includes/libs/ParamValidator/Util/UploadedFileStream.php [new file with mode: 0644]
includes/libs/ParamValidator/ValidationException.php [new file with mode: 0644]
tests/common/TestsAutoLoader.php
tests/phpunit/includes/libs/ParamValidator/ParamValidatorTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/SimpleCallbacksTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/BooleanDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/EnumDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/FloatDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/IntegerDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/LimitDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/PasswordDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/PresenceBooleanDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/StringDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/TimestampDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/TypeDefTestCase.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDef/UploadDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/TypeDefTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/Util/UploadedFileStreamTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/Util/UploadedFileTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/ParamValidator/Util/UploadedFileTestBase.php [new file with mode: 0644]