MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / validateStackProps

Function validateStackProps

packages/core/src/layout/validate/interactive.ts:172–246  ·  view source on GitHub ↗
(
  kind: "row" | "column",
  props: StackProps | unknown,
)

Source from the content-addressed store, hash-verified

170
171/** Validate Row/Column props: pad (default 0), gap (default 0), align (default "start"). */
172export function validateStackProps(
173 kind: "row" | "column",
174 props: StackProps | unknown,
175): LayoutResult<ValidatedStackProps> {
176 const propsRes = requirePropBag(kind, props);
177 if (!propsRes.ok) return propsRes;
178 const p = propsRes.value as StackPropBag;
179
180 const padRes = requireSpacingIntNonNegative(kind, "pad", p.pad, 0);
181 if (!padRes.ok) return padRes;
182 const gapRes = requireSpacingIntNonNegative(kind, "gap", p.gap, 0);
183 if (!gapRes.ok) return gapRes;
184
185 const alignRaw = resolveResponsiveValue(p.items ?? p.align);
186 const alignValue = alignRaw === undefined ? "start" : normalizeStringToken(alignRaw);
187 if (
188 alignValue !== "start" &&
189 alignValue !== "center" &&
190 alignValue !== "end" &&
191 alignValue !== "stretch"
192 ) {
193 return invalid(`${kind}.align must be one of "start" | "center" | "end" | "stretch"`);
194 }
195
196 const justifySource = resolveResponsiveValue(p.justify);
197 const justifyRaw = justifySource === undefined ? "start" : normalizeStringToken(justifySource);
198 const justifyValue =
199 justifyRaw === "space-between"
200 ? "between"
201 : justifyRaw === "space-around"
202 ? "around"
203 : justifyRaw === "space-evenly"
204 ? "evenly"
205 : justifyRaw;
206 if (
207 justifyValue !== "start" &&
208 justifyValue !== "end" &&
209 justifyValue !== "center" &&
210 justifyValue !== "between" &&
211 justifyValue !== "around" &&
212 justifyValue !== "evenly"
213 ) {
214 return invalid(
215 `${kind}.justify must be one of "start" | "end" | "center" | "between" | "around" | "evenly" (also accepts CSS aliases: "space-between" | "space-around" | "space-evenly")`,
216 );
217 }
218
219 const lcRes = validateLayoutConstraints(kind, p);
220 if (!lcRes.ok) return lcRes;
221 const normalizedConstraints: ValidatedLayoutConstraints = { ...lcRes.value };
222 const overflowRes = requireOverflow(kind, "overflow", p.overflow, "visible");
223 if (!overflowRes.ok) return overflowRes;
224 const scrollXRes = requireIntNonNegative(kind, "scrollX", p.scrollX, 0);
225 if (!scrollXRes.ok) return scrollXRes;
226 const scrollYRes = requireIntNonNegative(kind, "scrollY", p.scrollY, 0);
227 if (!scrollYRes.ok) return scrollYRes;
228
229 const spRes = validateSpacingProps(kind, p as unknown as Record<string, unknown>);

Callers 4

measureStackFunction · 0.85
layoutStackFunction · 0.85
measureStackIntrinsicFunction · 0.85
spacing.test.tsFile · 0.85

Calls 9

requirePropBagFunction · 0.85
resolveResponsiveValueFunction · 0.85
normalizeStringTokenFunction · 0.85
requireOverflowFunction · 0.85
requireIntNonNegativeFunction · 0.85
validateSpacingPropsFunction · 0.85
invalidFunction · 0.70

Tested by

no test coverage detected