Skip to content

Commit

Permalink
fix bug in undefined check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Maldonado authored and Jake Maldonado committed Apr 17, 2021
1 parent 72c3e0a commit dcf5ac2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/entity.put.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const TestEntity5 = new Entity({
autoExecute: false,
attributes: {
pk: { partitionKey: true },
test_required_number: { type: 'number', required: true },
test_required_boolean: { type: 'boolean', required: true },
test_required_number: { type: 'number', required: true },
},
table: TestTable2
})
Expand Down
5 changes: 2 additions & 3 deletions src/classes/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,8 @@ class Entity<


// Check for required fields
Object.keys(required).forEach(field =>
required[field] !== undefined && data[field] !== null && data[field] !== undefined
&& error(`'${field}${this.schema.attributes[field].alias ? `/${this.schema.attributes[field].alias}` : ''}' safasfda is a required field`)
Object.keys(required).forEach(field => required[field] !== undefined && (data[field] === undefined || data[field] === null)
&& error(`'${field}${this.schema.attributes[field].alias ? `/${this.schema.attributes[field].alias}` : ''}' is a required field`)
) // end required field check

// Checks for partition and sort keys
Expand Down

0 comments on commit dcf5ac2

Please sign in to comment.