我正在验证如下所示的请求:
{
"data": [
{
"id": 1,
"name": "Foo",
"values":{
"val1":"This",
"99":"That"
}
}
]
}
这是我的自定义消息:
$messages = [
'data.id'=>'is required',
'data.name'=>'is required',
'data.values'=>'must be array',
'data.values.*'=>'must be numeric'
];
我的验证规则是:
$this->validate(
$request,
[
'data'=>'required|array',
'data.*.id'=>'required|numeric',
'data.*.name'=>'required',
'data.*.values'=>'array',
'data.*.values.*'=>'numeric'
],
$messages
);
该规则验证“值”数组中的值。我想改为验证“值”数组[val1,99]中的键。
答案 0 :(得分:1)
为 using UnityEngine;
using System.Collections;
public class Mover : MonoBehaviour
{
public float speed;
public new Rigidbody2D rigidbody;
public bool random;
void Start()
{
if (random) {
rigidbody.velocity = Random.value * transform.right * speed;
}
else
{
rigidbody.velocity = transform.right * speed;
}
}
}
编写自定义验证规则:
data.*.values