Vendor lock

This commit is contained in:
2023-06-16 02:08:47 +00:00
parent 7933e70e90
commit 3351b92dd6
4099 changed files with 345789 additions and 0 deletions

27
vendor/j4mie/paris/docs/validation.rst vendored Normal file
View File

@ -0,0 +1,27 @@
A word on validation
====================
Its generally considered a good idea to centralise your data validation
in a single place, and a good place to do this is inside your model
classes. This is preferable to handling validation alongside form
handling code, for example. Placing validation code inside models means
that if you extend your application in the future to update your model
via an alternative route (say a REST API rather than a form) you can
re-use the same validation code.
Despite this, Paris doesnt provide any built-in support for validation.
This is because validation is potentially quite complex, and often very
application-specific. Paris is deliberately quite ignorant about your
actual data - it simply executes queries, and gives you the
responsibility of making sure the data inside your models is valid and
correct. Adding a full validation framework to Paris would probably
require more code than Paris itself!
However, there are several simple ways that you could add validation to
your models without any help from Paris. You could override the
``save()`` method, check the data is valid, and return ``false`` on
failure, or call ``parent::save()`` on success. You could create your
own subclass of the ``Model`` base class and add your own generic
validation methods. Or you could write your own external validation
framework which you pass model instances to for checking. Choose
whichever approach is most suitable for your own requirements.