Hyperlinkv0.8.0-beta.28

Schema

Schema.isBase64functioneffect/Schema.ts:6783
(annotations?: Annotations.Filter): SchemaAST.Filter<string>

Validates that a string is valid Base64 encoded data.

Details

JSON Schema:

This check corresponds to a pattern constraint in JSON Schema that matches Base64 format.

Arbitrary:

When generating test data with fast-check, this applies a patterns constraint to ensure generated strings match the Base64 pattern.

String checks
Source effect/Schema.ts:678314 lines
export function isBase64(annotations?: Annotations.Filter) {
  const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/
  return isPattern(
    regExp,
    {
      expected: "a base64 encoded string",
      meta: {
        _tag: "isBase64",
        regExp
      },
      ...annotations
    }
  )
}
Referenced by 2 symbols