Now violentUssageName field in meta is required

This commit is contained in:
yutopp
2019-02-01 18:59:59 +09:00
parent 76abf901f1
commit 1632e9de40
2 changed files with 44 additions and 3 deletions

View File

@@ -241,10 +241,11 @@ namespace VRM
{
licenseName = "CC0",
allowedUserName = "OnlyAuthor",
violentUssageName = "Disallow",
};
var json = model.ToJson();
Assert.AreEqual(@"{""texture"":-1,""allowedUserName"":""OnlyAuthor"",""licenseName"":""CC0""}", json);
Assert.AreEqual(@"{""texture"":-1,""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""licenseName"":""CC0""}", json);
Debug.Log(json);
var c = new JsonSchemaValidationContext("")
@@ -253,7 +254,7 @@ namespace VRM
};
var json2 = JsonSchema.FromType<glTF_VRM_Meta>().Serialize(model, c);
// NOTE: New serializer outputs values which will not be used...
Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""licenseName"":""CC0""}",json2);
Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""licenseName"":""CC0""}",json2);
}
[Test]
@@ -276,6 +277,7 @@ namespace VRM
var model = new glTF_VRM_Meta()
{
allowedUserName = "OnlyAuthor",
violentUssageName = "Disallow",
licenseName = "_INVALID_SOME_THING_",
};
@@ -292,7 +294,9 @@ namespace VRM
{
var model = new glTF_VRM_Meta()
{
// allowedUserName = "OnlyAuthor",
licenseName = "CC0",
violentUssageName = "Disallow",
};
var c = new JsonSchemaValidationContext("")
@@ -309,6 +313,7 @@ namespace VRM
var model = new glTF_VRM_Meta()
{
allowedUserName = "_INVALID_SOME_THING_",
violentUssageName = "Disallow",
licenseName = "CC0",
};
@@ -321,6 +326,42 @@ namespace VRM
);
Assert.AreEqual("[allowedUserName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
}
{
var model = new glTF_VRM_Meta()
{
allowedUserName = "OnlyAuthor",
//violentUssageName = "Disallow",
licenseName = "CC0",
};
var c = new JsonSchemaValidationContext("")
{
EnableDiagnosisForNotRequiredFields = true,
};
var ex = Assert.Throws<JsonSchemaValidationException>(
() => JsonSchema.FromType<glTF_VRM_Meta>().Serialize(model, c)
);
Assert.AreEqual("[violentUssageName.String] null", ex.Message);
}
{
var model = new glTF_VRM_Meta()
{
allowedUserName = "OnlyAuthor",
violentUssageName = "_INVALID_SOME_THING_",
licenseName = "CC0",
};
var c = new JsonSchemaValidationContext("")
{
EnableDiagnosisForNotRequiredFields = true,
};
var ex = Assert.Throws<JsonSchemaValidationException>(
() => JsonSchema.FromType<glTF_VRM_Meta>().Serialize(model, c)
);
Assert.AreEqual("[violentUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message);
}
}
// TODO: Move to another suitable location

View File

@@ -77,7 +77,7 @@ namespace VRM
}
}
[JsonSchema(Description = "Permission to perform violent acts with this avatar", EnumValues = new object[]
[JsonSchema(Required = true, Description = "Permission to perform violent acts with this avatar", EnumValues = new object[]
{
"Disallow",
"Allow",