File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,23 @@ const defaultValues: MemberAddForm = {
4343
4444type ValidationErrors = Partial < Record < keyof MemberAddForm , string > >
4545
46- export function validateMember ( poolVersion : IpVersion , values : MemberAddForm ) {
46+ /**
47+ * This function is a sneaky way to back into cross-field validation while only
48+ * hooking into the field-level `validate` callback. This function looks at all
49+ * the form `values` together and sets errors for each field in the form, and
50+ * then the callsites look like this: they all call it the same way and just
51+ * pluck their own error off the result.
52+ *
53+ * ```ts
54+ * validate={(_maxPrefixLength, values) =>
55+ * validateMember(poolData.ipVersion, values).maxPrefixLength
56+ * }
57+ * ```
58+ */
59+ export function validateMember (
60+ poolVersion : IpVersion ,
61+ values : MemberAddForm
62+ ) : ValidationErrors {
4763 const maxBound = poolVersion === 'v4' ? 32 : 128
4864 const parsed = parseIpNet ( values . subnet )
4965 const { minPrefixLength : minPL , maxPrefixLength : maxPL } = values
You can’t perform that action at this time.
0 commit comments