base64 function

LivrRule base64(
  1. List<Object?> args,
  2. RuleContext context
)

base64: the value must be Base64 (RFC 4648): the alphabet A-Za-z0-9+/, a length that is a multiple of 4, and the padding = or == only at the end. {base64: 'url'} takes the URL-safe alphabet A-Za-z0-9-_, with the padding complete or absent. No whitespace. The output is the value as a string.

Implementation

LivrRule base64(List<Object?> args, RuleContext context) {
  if (args.isEmpty) return _base64;
  // Arguments after the variant are ignored
  if (args[0] == 'url') return _base64Url;
  throw LivrSchemaException(
    'Rule [base64] expects no arguments or "url", got [${args[0]}]',
  );
}