'use strict';

const Hoek = require('hoek');
const Joi = require('joi');
const recordBase = require('./record_base');

module.exports = Hoek.clone(recordBase).keys({
  record_type: Joi.string().valid('TXT').required(),
  text_content: Joi.string().required()
});

@@ -218,44 +218,395 @@
 ,%0A  
-text_content: Joi.string().required(
+// Allowed in TXT records are ASCII letters, plus a selected set of%0A  // symbols, which translates to this gobbledygook you see in the regex%0A  // below. The %5C%5B%5C%5C%5C%5D%5C sequence just whitelists the characters %5B%5C%5D, but%0A  // since they all need escaping in regex, it becomes a bit strange.%0A  text_content: Joi.string().required().regex(/%5E%5BA-Za-z0-9 !%22#%5C$%25&'()*+,-.%5C/:;%3C=%3E?@%5C%5B%5C%5C%5C%5D%5C%5E_%60%7B%5C%7C%7D~-%5D+$/
 )%0A%7D)

Whitelist for characters in TXT records