"use strict";

const matchesFormat = require("@validatem/matches-format");

const isCollectionName = require("./is-collection-name");
const isLocalFieldName = require("./is-local-field-name");

module.exports = [
	// FIXME: Validate format properly
	matchesFormat(/^[^.]+\.[^.]+$/),
	(string) => {
		let [ collectionName, fieldName ] = string.split(".");
		
		return {
			collection: collectionName,
			field: fieldName
		};
	},
	{ // FIXME: Make any validation errors at this point be represented as virtual properties, as it's a parse result
		collection: [ isCollectionName ],
		field: [ isLocalFieldName ]
	}
];
