Hello ! I am looking for a solution to have a cust...
# support-questions
Hello ! I am looking for a solution to have a custom password validation according to a client. My first idea is to add a password formfield validate method (https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/signup-form/field-validators#step-2-back-end-) But to do this i need to call an API inside the validate method with a clientId (so the front need to send this ID to the validate method), is there a way to do this? Thanks in advance for your help πŸ™‚
Hi @Romain , If you are using the
on the frontend you could add your custom validator on the frontend itself
Unfortunately it will be the supertoken javascript (we are in VueJs)
And having the validation only on the front end doesn't cover us from a user who would signup with a direct API call 😒
Right, one way to do that is to return
in the validator (the one you linked to) for password. This will disable the SDKs validation for it You can then use our override feature to override the sign in/sign up functions and perform your validation there
Okay I will try this thanks πŸ™‚ And I can pass the clientId from the front in an override method ?
For the backend, the input to the function will include details from the request. You should be able to access the client id from there. For the frontend since you are using the supertokens-website sdk you just add it as you normally would to the body, headers etc
Perfect, it's look nice πŸ™‚ Many thanks !
@RomainJust a slight correction, you would need to override the API to get access to the client id https://supertokens.com/docs/thirdpartyemailpassword/advanced-customizations/apis-override/usage
You can then use our userContext feature to pass it to the function https://supertokens.com/docs/thirdpartyemailpassword/advanced-customizations/user-context
Great, thanks to you for your help, I will try to implement this! πŸ™‚
It work very well, but i have to return this in the
function override, it's a good practice ?
Copy code
throw new EmailPassword.Error({
    type: 'FIELD_ERROR',
    payload: [
        id: 'password',
        error: 'Password must contain at least 12 character',
    message: 'Error in input formFields',
@nkshah2 πŸ™‚
You should return with status field error (the api spec can help here)
Other than that it’s fine
It's not a status field error here ?
Ah right my mistake, yeah that works fine
Perfect thanks πŸ™‚