-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredential.ts
More file actions
22 lines (19 loc) · 738 Bytes
/
credential.ts
File metadata and controls
22 lines (19 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { validator } from "hono/validator";
import { ERR_CREDENTIAL_INVALID } from "@/lib/error/static";
/**
* Verify the initial credential (e.g. email, phone number...) before generating and sending an OTP.
*
* - Customize this validator as you like, but it must be a form validator.
* - The validation target must return a credential string (it is not shared with the client).
* - Read more about [Hono validators](https://hono.dev/docs/guides/validation#validation).
*/
const credentialValidator = validator("form", (body, c) => {
/**
* Is the body empty?
*/
if (!Object.keys(body).length) {
return c.json(ERR_CREDENTIAL_INVALID, 400);
}
return JSON.stringify(body);
});
export default credentialValidator;