diff --git a/vendor/xaboy/form-builder/demo.jpg b/vendor/xaboy/form-builder/demo.jpg deleted file mode 100644 index a47392e6..00000000 Binary files a/vendor/xaboy/form-builder/demo.jpg and /dev/null differ diff --git a/vendor/xaboy/form-builder/src/components/Validate.php b/vendor/xaboy/form-builder/src/components/Validate.php new file mode 100644 index 00000000..fc4e8916 --- /dev/null +++ b/vendor/xaboy/form-builder/src/components/Validate.php @@ -0,0 +1,185 @@ +type = $type; + $this->trigger = $trigger; + } + + public static function str($trigger = self::TRIGGER_CHANGE) + { + return new static(self::TYPE_STRING,$trigger); + } + + public static function arr($trigger = self::TRIGGER_CHANGE) + { + return new static(self::TYPE_ARRAY,$trigger); + } + + public static function num($trigger = self::TRIGGER_CHANGE) + { + return new static(self::TYPE_NUMBER,$trigger); + } + + public static function date($trigger = self::TRIGGER_CHANGE) + { + return new static(self::TYPE_DATE,$trigger); + } + + protected function set($validate, $message = null) + { + $this->validate[] = $validate + [ + 'trigger' => $this->trigger, + 'type' => $this->type, + 'message' => $message + ]; + } + + /** + * 必须为链接 + * @param string|null $message + * @return $this + */ + public function url($message = null) + { + $this->set([ + 'type'=>'url' + ],$message); + return $this; + } + + /** + * 必须为邮箱 + * @param string|null $message + * @return $this + */ + public function email($message = null) + { + $this->set([ + 'type'=>'email' + ],$message); + return $this; + } + + /** + * 必填 + * @param string|null $message + * @return $this + */ + public function required($message = null) + { + $this->set([ + 'required' => true, + ], $message); + return $this; + } + + /** + * 长度或值必须在这个范围内 + * @param int $min + * @param int $max + * @param string|null $message + * @return $this + */ + public function range($min, $max, $message = null) + { + $this->set([ + 'min' => (int)$min, + 'max' => (int)$max, + ], $message); + return $this; + } + + /** + * 长度或值必须大于这个值 + * @param int $min + * @param string|null $message + * @return $this + */ + public function min($min, $message = null) + { + $this->set([ + 'min' => (int)$min, + ], $message); + return $this; + } + + /** + * 长度或值必须小于这个值 + * @param int $max + * @param string|null $message + * @return $this + */ + public function max($max, $message = null) + { + $this->set([ + 'max' => (int)$max, + ], $message); + return $this; + } + + /** + * 长度或值必须等于这个值 + * @param int $length + * @param string|null $message + * @return $this + */ + public function length($length, $message = null) + { + $this->set([ + 'length' => (int)$length + ], $message); + return $this; + } + + /** + * 值必须在 list 中 + * @param array $list + * @param string|null $message + * @return $this + */ + public function enum($list, $message = null) + { + $this->set([ + 'type'=>'enum', + 'enum' => (array)$list + ], $message); + return $this; + } + + public function build() + { + return $this->validate; + } +} \ No newline at end of file diff --git a/vendor/xaboy/form-builder/src/traits/form/FormValidateTrait.php b/vendor/xaboy/form-builder/src/traits/form/FormValidateTrait.php new file mode 100644 index 00000000..63651e1d --- /dev/null +++ b/vendor/xaboy/form-builder/src/traits/form/FormValidateTrait.php @@ -0,0 +1,49 @@ +