(deriveOptions: {
readonly order: Order.Order<T>
readonly annotate?:
| ((options: {
readonly minimum: T
readonly maximum: T
readonly exclusiveMinimum?: boolean | undefined
readonly exclusiveMaximum?: boolean | undefined
}) => Annotations.Filter)
| undefined
readonly formatter?: Formatter<T> | undefined
})
| 7185 | * |
| 7186 | * @category validation |
| 7187 | * @since 4.0.0 |
| 7188 | */ |
| 7189 | export const isBase64UrlReviver: SchemaRepresentation.FilterReviver<null> = InternalSchema.makeFilterReviver( |
| 7190 | "effect/schema/isBase64Url", |
| 7191 | Null, |
| 7192 | ({ annotations }) => isBase64Url(annotations) |
| 7193 | ) |
| 7194 | |
| 7195 | /** |
| 7196 | * Validates at runtime that a string starts with the specified literal prefix. |
| 7197 | * |
| 7198 | * **Details** |
| 7199 | * |
| 7200 | * RegExp metacharacters in the prefix are escaped in JSON Schema and arbitrary |
| 7201 | * metadata so that the generated patterns retain literal `startsWith` semantics. |
| 7202 | * |
| 7203 | * @category validation |
| 7204 | * @since 4.0.0 |
| 7205 | */ |
| 7206 | export function isStartsWith(startsWith: string, annotations?: Annotations.Filter) { |
| 7207 | const formatted = JSON.stringify(startsWith) |
| 7208 | const regExp = new globalThis.RegExp(`^${RegExp_.escape(startsWith)}`) |
| 7209 | return makeFilter( |
| 7210 | (s: string) => s.startsWith(startsWith), |
| 7211 | { |
| 7212 | expected: `a string starting with ${formatted}`, |
| 7213 | representation: { |
| 7214 | id: "effect/schema/isStartsWith", |
| 7215 | payload: { startsWith } |
| 7216 | }, |
| 7217 | toJsonSchema: () => ({ pattern: regExp.source }), |
| 7218 | toCode: () => ({ runtime: `Schema.isStartsWith(${format(startsWith)})` }), |
| 7219 | arbitrary: { |
| 7220 | constraint: { |
| 7221 | patterns: [regExp.source] |
| 7222 | } |
| 7223 | }, |
| 7224 | ...annotations |
| 7225 | } |
| 7226 | ) |
| 7227 | } |
| 7228 | |
| 7229 | /** |
| 7230 | * Reviver for persisted `isStartsWith` checks. |
| 7231 | * |
| 7232 | * **When to use** |
| 7233 | * |
| 7234 | * Use when reconstructing documents that may contain checks created by {@link isStartsWith}. |
| 7235 | * |
| 7236 | * @see {@link isStartsWith} for creating the corresponding check |
| 7237 | * |
no test coverage detected
searching dependent graphs…