You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SafeValidator.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\validators;
  8. /**
  9. * SafeValidator serves as a dummy validator whose main purpose is to mark the attributes to be safe for massive assignment.
  10. *
  11. * This class is required because of the way in which Yii determines whether a property is safe for massive assignment, that is,
  12. * when a user submits form data to be loaded into a model directly from the POST data, is it ok for a property to be copied.
  13. * In many cases, this is required but because sometimes properties are internal and you do not want the POST data to be able to
  14. * override these internal values (especially things like database row ids), Yii assumes all values are unsafe for massive assignment
  15. * unless a validation rule exists for the property, which in most cases it will. Sometimes, however, an item is safe for massive assigment but
  16. * does not have a validation rule associated with it - for instance, due to no validation being performed, in which case, you use this class
  17. * as a validation rule for that property. Although it has no functionality, it allows Yii to determine that the property is safe to copy.
  18. *
  19. * @author Qiang Xue <qiang.xue@gmail.com>
  20. * @since 2.0
  21. */
  22. class SafeValidator extends Validator
  23. {
  24. /**
  25. * @inheritdoc
  26. */
  27. public function validateAttributes($model, $attributes = null)
  28. {
  29. }
  30. /**
  31. * @inheritdoc
  32. */
  33. public function validateAttribute($model, $attribute)
  34. {
  35. }
  36. }