|
|
@@ -1574,6 +1574,25 @@ class Validator implements ArrayAccess, IteratorAggregate, Countable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Add a validation rule to ensure a field is a 6 digits hex color value.
|
|
|
+ *
|
|
|
+ * @param string $field The field you want to apply the rule to.
|
|
|
+ * @param string|null $message The error message when the rule fails.
|
|
|
+ * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
|
|
|
+ * true when the validation rule should be applied.
|
|
|
+ * @see \Cake\Validation\Validation::color()
|
|
|
+ * @return $this
|
|
|
+ */
|
|
|
+ public function hexColor($field, $message = null, $when = null)
|
|
|
+ {
|
|
|
+ $extra = array_filter(['on' => $when, 'message' => $message]);
|
|
|
+
|
|
|
+ return $this->add($field, 'hexColor', $extra + [
|
|
|
+ 'rule' => 'hexColor',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Add a validation rule for a multiple select. Comparison is case sensitive by default.
|
|
|
*
|
|
|
* @param string $field The field you want to apply the rule to.
|