using FluentValidation; namespace SatelliteProvider.Api.Validators; // AZ-795 / AZ-796: process-wide FluentValidation configuration shared by the // API host and unit tests. Tests must call ApplyOnce() in their fixture setup // so the property-name casing they assert against matches what the running // API will produce — see `_docs/02_document/contracts/api/error-shape.md` // invariant Inv-4 (camelCase paths in `errors` map). public static class GlobalValidatorConfig { private static readonly object _gate = new(); private static bool _applied; public static void ApplyOnce() { lock (_gate) { if (_applied) return; ValidatorOptions.Global.PropertyNameResolver = (type, member, expression) => { var name = member?.Name; if (string.IsNullOrEmpty(name)) return null; return char.ToLowerInvariant(name[0]) + name[1..]; }; _applied = true; } } }