| 10220 | * @since 4.0.0 |
| 10221 | */ |
| 10222 | export function RedactedFromValue<S extends Constraint>(value: S, options?: { |
| 10223 | readonly label?: string | undefined |
| 10224 | readonly disallowEncode?: boolean | undefined |
| 10225 | }): RedactedFromValue<S> { |
| 10226 | return decodeTo<Redacted<toType<S>>, S>( |
| 10227 | Redacted(toType(value), { |
| 10228 | label: options?.label, |
| 10229 | disallowJsonEncode: options?.disallowEncode |
| 10230 | }), |
| 10231 | { |
| 10232 | decode: SchemaGetter.transform((t) => Redacted_.make(t, { label: options?.label })), |
| 10233 | encode: options?.disallowEncode ? |
| 10234 | SchemaGetter.forbidden((oe) => |
| 10235 | "Cannot encode Redacted" + |
| 10236 | (Option_.isSome(oe) && typeof oe.value.label === "string" ? ` with label: "${oe.value.label}"` : "") |
| 10237 | ) : |
| 10238 | SchemaGetter.transform(Redacted_.value) |
| 10239 | } |
| 10240 | )(value) |
| 10241 | } |
| 10242 | |
| 10243 | /** |
| 10244 | * Type-level representation returned by {@link CauseReason}. |