update js samples

This commit is contained in:
William Cheng
2024-02-06 17:00:49 +08:00
parent 2f3f684b7f
commit 963e16a0dd
33 changed files with 33 additions and 33 deletions

View File

@@ -67,7 +67,7 @@ class Animal {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Animal.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -69,7 +69,7 @@ class BasquePig {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of BasquePig.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -68,7 +68,7 @@ class Cat {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Cat.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -67,7 +67,7 @@ class Category {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Category.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -69,7 +69,7 @@ class DanishPig {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of DanishPig.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -68,7 +68,7 @@ class Dog {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Dog.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -89,7 +89,7 @@ class EnumTest {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of EnumTest.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -115,7 +115,7 @@ class FormatTest {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of FormatTest.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -74,7 +74,7 @@ class Name {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Name.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -65,7 +65,7 @@ class OuterObjectWithEnumProperty {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of OuterObjectWithEnumProperty.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}

View File

@@ -83,7 +83,7 @@ class Pet {
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of Pet.RequiredProperties) {
if (!data[property]) {
if (!data.hasOwnProperty(property)) {
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
}
}