dotnet/aspnetcore · error
EqualTo validator requires a non-empty "other" parameter.
Error message
EqualTo validator requires a non-empty "other" parameter.
What it means
Thrown by the EqualTo validator (EqualTo.ts:13) when params.other is falsy. EqualTo implements [Compare]/confirm-field semantics (e.g., password == confirmPassword): it must know the name of the other form field to read and compare against. Without 'other' the rule has nothing to compare to, so it throws rather than silently passing or failing.
Source
Thrown at src/Components/Web.JS/src/Validation/Validators/EqualTo.ts:13
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
import { ValidationContext, ValidationResult, Validator, pass, fail } from '../ValidationTypes';
// Validates that the value equals another field's value (for password confirmation, etc.).
// Resolves "*.PropertyName" to the model-prefixed field name using the current field's name.
// Finds the other field by [name] attribute within the same form.
// Throws if the mandatory `other` parameter is missing.
export const equalToValidator: Validator = (context: ValidationContext): ValidationResult => {
const { value, element, params } = context;
if (!params.other) {
throw new Error('EqualTo validator requires a non-empty "other" parameter.');
}
if (!value) {
return pass();
}
const otherFieldName = resolveOtherFieldName(element.name, params.other);
if (!otherFieldName) {
return pass();
}
const form = element.closest('form');
if (!form) {
return pass();
}
const otherElement = form.querySelector<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(`[name="${CSS.escape(otherFieldName)}"]`);
View on GitHub (pinned to 294cab2f9b)
Solutions
- Ensure the model property has [Compare("OtherProperty")] and that the rendered <input> carries data-val-equalto-other="OtherProperty".
- If wiring the validator manually, always pass params: { other: '<otherFieldName>' } and use the *.Prefix form for model-prefixed fields.
- Verify the other field exists in the same <form> with a matching name attribute.
- Check that no custom CSS isolation/tag helper is stripping data-* attributes from the input.
Example fix
// before — Compare without target <input name="Password" data-val-equalto /> // after <input name="Password" data-val-equalto data-val-equalto-other="ConfirmPassword" /> <input name="ConfirmPassword" />
Defensive patterns
Strategy: validation
Validate before calling
function hasCompareOther(params: Record<string, unknown>): boolean {
return Boolean(params && typeof params.other === 'string' && params.other.length > 0);
} Type guard
function isEqualToConfigured(p: any): p is { other: string } {
return p && typeof p.other === 'string' && p.other.trim().length > 0;
} Prevention
- Always pair [Compare("Other")] with both inputs rendered in the same form.
- Verify data-val-equalto-other is present in the rendered HTML.
- When wiring manually, always pass { other: '<field>' }.
- Use the *.Prefix form for model-prefixed fields.
When it happens
Trigger: Registering or invoking the equalTo validator on a field whose data-validation params object lacks an 'other' key, or has other='' / null. Typically the param is emitted from a [Compare(OtherProperty=...)] attribute; if the attribute is misconfigured or the param emission is skipped, the JS validator receives no 'other'.
Common situations: Using [Compare] in a form but the validation metadata attribute on the field is missing or stripped (e.g., custom tag helper that omits data-val-equalto-other). Manually wiring validators and forgetting to pass { other: 'ConfirmPassword' }. Razor Pages/EditForm that does not render the comparison field's data-val attributes.
Related errors
- FileExtensions validator requires a non-empty "extensions" p
- Range validator requires at least one of "min" or "max" para
- regex validator requires a non-empty "pattern" parameter.
- length/minlength/maxlength validator requires at least one o
- Unknown passkey operation '${this.attrs.operation}'.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/4a777e6f0dbdc78c.
Report an issue: GitHub.