"use strict";

const required = require("@validatem/required");
const isString = require("@validatem/is-string");
const isPlainObject = require("@validatem/is-plain-object");

const isRoomEvent = require("../is-room-event");

module.exports = function isStateEvent(strict = false, extraFields = {}) {
	return isRoomEvent(strict, {
		state_key: [ required, isString ],
		prev_content: isPlainObject,
		// Spec violation by Synapse: https://github.com/matrix-org/synapse/issues/6226
		membership: [ isString ],
		... extraFields
	});
};
