MCPcopy Create free account
hub / github.com/angular/angular / readonly

Function readonly

packages/forms/signals/src/api/rules/readonly.ts:44–64  ·  view source on GitHub ↗
(
  path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
  configOrLogic?:
    | {when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>}
    | NoInfer<LogicFn<TValue, boolean, TPathKind>>,
)

Source from the content-addressed store, hash-verified

42): void;
43
44export function readonly<TValue, TPathKind extends PathKind = PathKind.Root>(
45 path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
46 configOrLogic?:
47 | {when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>}
48 | NoInfer<LogicFn<TValue, boolean, TPathKind>>,
49) {
50 assertPathIsCurrent(path);
51
52 const pathNode = FieldPathNode.unwrapFieldPath(path);
53
54 let logic: LogicFn<TValue, boolean, TPathKind>;
55 if (typeof configOrLogic === 'object' && configOrLogic !== null && 'when' in configOrLogic) {
56 logic = configOrLogic.when ?? (() => true);
57 } else if (typeof configOrLogic === 'function') {
58 logic = configOrLogic;
59 } else {
60 logic = () => true;
61 }
62
63 pathNode.builder.addReadonlyRule(logic);
64}

Callers 5

TestCmpClass · 0.90
TestCmpClass · 0.85
field_node.spec.tsFile · 0.85
submit.spec.tsFile · 0.85
compat.spec.tsFile · 0.85

Calls 3

assertPathIsCurrentFunction · 0.90
unwrapFieldPathMethod · 0.80
addReadonlyRuleMethod · 0.45

Tested by

no test coverage detected