Skip to content

Commit 682e290

Browse files
committed
Reject early for invalid arguments
1 parent 187fa87 commit 682e290

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: control-flow/sequential-execution/triple-encryption.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import bcrypt from 'bcrypt';
22

33
function encrypt (text, rounds) {
4+
if (!text || typeof text !== "string") {
5+
return Promise.reject(new Error("Invalid text argument"));
6+
}
7+
8+
if (!rounds || typeof rounds !== "number") {
9+
return Promise.reject(new Error("Invalid rounds argument"));
10+
}
11+
412
return bcrypt.hash(text, rounds);
513
}
614

0 commit comments

Comments
 (0)