evaluateChangePasswordForm()
evaluateChangePasswordForm evaluates a full change-credential form (new value + confirmation) against a policy in one call, so a live requirement checklist and a submit gate can never disagree about what counts as valid. This is what <ChangeCredential /> uses internally in the React and Vue SDKs.
Signature
evaluateChangePasswordForm(
values: ChangePasswordFormValues,
policy: PasswordPolicy,
): ChangePasswordFormEvaluation
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
values.newPassword | string | ✅ | The value to set. |
values.confirmPassword | string | ✅ | The re-typed value, used only to catch typos client-side. |
policy | PasswordPolicy | ✅ | The rules newPassword must satisfy. See resolveChangeCredentialPolicy(). |
There is deliberately no currentPassword field. The self-service credential write path does not verify the account's existing value today, so a field the server ignores would only teach the user a false sense of security.
Returns
ChangePasswordFormEvaluation
| Property | Type | Description |
|---|---|---|
confirmMatches | boolean | Whether newPassword and confirmPassword match. |
isValid | boolean | Whether the values are complete and internally consistent. Combine with your own in-flight flag, since a pending request is UI state rather than validation. |
meetsPolicy | boolean | Whether newPassword satisfies every configured rule. |
ruleResults | PasswordRuleResult[] | Per-rule results, for the live requirement checklist. |
Usage
import { evaluateChangePasswordForm } from '@thunderid/browser'
const { isValid, ruleResults } = evaluateChangePasswordForm(
{ newPassword, confirmPassword },
{ regex: '^.{12,}$' },
)
const canSubmit = !loading && isValid
Related
updateMeCredentials(): Submit the value once the form is validevaluatePasswordPolicy(): The single-value check this builds onresolveChangeCredentialPolicy(): Derive the policy from the user type schema