Closed 596868636 closed 1 year ago
PR需求来源:https://www.workerman.net/q/11421
用法 $data = v::input($request->post(), [ 'app_id' => v::alnum()->length(1, 64)->setName('用户名')->setDefault("toadmin"), 'app_id1' => v::alnum()->length(1, 64)->setName('用户名')->setDefault("toadmin",true), 'xxx' => v::optional(v::length(5, 64))->setName('其它'), 'xxx1' => v::length(5, 64)->setDefault('其它111') ]);
使用setDefault后,同时可代替v::optional用于验证一些字段可填可不填字段中,同时可以使用setDefaule第二个参数为true即可设置为强制默认值,而不被前端传输的参数替换,比如app_id1,我需要固定为“toadmin”,而不被前端传输app_id1为touser而覆盖。 而验证后的变量 $data 即可传输到service等层进行业务处理
PR需求来源:https://www.workerman.net/q/11421
用法 $data = v::input($request->post(), [ 'app_id' => v::alnum()->length(1, 64)->setName('用户名')->setDefault("toadmin"), 'app_id1' => v::alnum()->length(1, 64)->setName('用户名')->setDefault("toadmin",true), 'xxx' => v::optional(v::length(5, 64))->setName('其它'), 'xxx1' => v::length(5, 64)->setDefault('其它111') ]);