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