14
14
* limitations under the License.
15
15
*/
16
16
17
- import { z } from "zod" ;
17
+ import * as z from "zod" ;
18
18
import { RecaptchaVerifier } from "firebase/auth" ;
19
19
import { getTranslation } from "./translations" ;
20
20
import { FirebaseUIConfiguration } from "./config" ;
@@ -25,38 +25,38 @@ export type AuthMode = "signIn" | "signUp";
25
25
26
26
export function createSignInAuthFormSchema ( ui : FirebaseUIConfiguration ) {
27
27
return z . object ( {
28
- email : z . string ( ) . email ( { message : getTranslation ( ui , "errors" , "invalidEmail" ) } ) ,
29
- password : z . string ( ) . min ( 8 , { message : getTranslation ( ui , "errors" , "weakPassword" ) } ) ,
28
+ email : z . email ( getTranslation ( ui , "errors" , "invalidEmail" ) ) ,
29
+ password : z . string ( ) . min ( 8 , getTranslation ( ui , "errors" , "weakPassword" ) ) ,
30
30
} ) ;
31
31
}
32
32
33
33
export function createSignUpAuthFormSchema ( ui : FirebaseUIConfiguration ) {
34
34
return z . object ( {
35
- email : z . string ( ) . email ( { message : getTranslation ( ui , "errors" , "invalidEmail" ) } ) ,
36
- password : z . string ( ) . min ( 8 , { message : getTranslation ( ui , "errors" , "weakPassword" ) } ) ,
35
+ email : z . email ( getTranslation ( ui , "errors" , "invalidEmail" ) ) ,
36
+ password : z . string ( ) . min ( 6 , getTranslation ( ui , "errors" , "weakPassword" ) ) ,
37
37
} ) ;
38
38
}
39
39
40
40
export function createForgotPasswordAuthFormSchema ( ui : FirebaseUIConfiguration ) {
41
41
return z . object ( {
42
- email : z . string ( ) . email ( { message : getTranslation ( ui , "errors" , "invalidEmail" ) } ) ,
42
+ email : z . email ( getTranslation ( ui , "errors" , "invalidEmail" ) ) ,
43
43
} ) ;
44
44
}
45
45
46
46
export function createEmailLinkAuthFormSchema ( ui : FirebaseUIConfiguration ) {
47
47
return z . object ( {
48
- email : z . string ( ) . email ( { message : getTranslation ( ui , "errors" , "invalidEmail" ) } ) ,
48
+ email : z . email ( getTranslation ( ui , "errors" , "invalidEmail" ) ) ,
49
49
} ) ;
50
50
}
51
51
52
52
export function createPhoneAuthFormSchema ( ui : FirebaseUIConfiguration ) {
53
53
return z . object ( {
54
54
phoneNumber : z
55
55
. string ( )
56
- . min ( 1 , { message : getTranslation ( ui , "errors" , "missingPhoneNumber" ) } )
57
- . max ( 10 , { message : getTranslation ( ui , "errors" , "invalidPhoneNumber" ) } ) ,
56
+ . min ( 1 , getTranslation ( ui , "errors" , "missingPhoneNumber" ) )
57
+ . max ( 10 , getTranslation ( ui , "errors" , "invalidPhoneNumber" ) ) ,
58
58
verificationCode : z . string ( ) . refine ( ( val ) => ! val || val . length >= 6 , {
59
- message : getTranslation ( ui , "errors" , "invalidVerificationCode" ) ,
59
+ error : getTranslation ( ui , "errors" , "invalidVerificationCode" ) ,
60
60
} ) ,
61
61
recaptchaVerifier : z . instanceof ( RecaptchaVerifier ) ,
62
62
} ) ;
0 commit comments