<commit_before>import flattenReference from '../../utils/flattenReference.js';

const validBuiltins = new Set([
	'set',
	'fire',
	'destroy'
]);

export default function validateElement ( validator, node ) {
	const isComponent = node.name === ':Self' || validator.components.has( node.name );

	node.attributes.forEach( attribute => {
		if ( !isComponent && attribute.type === 'Binding' ) {
			const { name } = attribute;

			if ( name === 'value' ) {
				if ( node.name !== 'input' && node.name !== 'textarea' && node.name !== 'select' ) {
					validator.error( `'value' is not a valid binding on <${node.name}> elements`, attribute.start );
				}
			}

			else if ( name === 'checked' ) {
				if ( node.name !== 'input' ) {
					validator.error( `'checked' is not a valid binding on <${node.name}> elements`, attribute.start );
				}

				if ( getType( validator, node ) !== 'checkbox' ) {
					validator.error( `'checked' binding can only be used with <input type="checkbox">` );
				}
			}

			else if ( name === 'group' ) {
				if ( node.name !== 'input' ) {
					validator.error( `'group' is not a valid binding on <${node.name}> elements`, attribute.start );
				}

				const type = getType( validator, node );
<commit_msg>Provide second argument to validator.error with bind:checked errors<commit_after>import flattenReference from '../../utils/flattenReference.js';

const validBuiltins = new Set([
	'set',
	'fire',
	'destroy'
]);

export default function validateElement ( validator, node ) {
	const isComponent = node.name === ':Self' || validator.components.has( node.name );

	node.attributes.forEach( attribute => {
		if ( !isComponent && attribute.type === 'Binding' ) {
			const { name } = attribute;

			if ( name === 'value' ) {
				if ( node.name !== 'input' && node.name !== 'textarea' && node.name !== 'select' ) {
					validator.error( `'value' is not a valid binding on <${node.name}> elements`, attribute.start );
				}
			}

			else if ( name === 'checked' ) {
				if ( node.name !== 'input' ) {
					validator.error( `'checked' is not a valid binding on <${node.name}> elements`, attribute.start );
				}

				if ( getType( validator, node ) !== 'checkbox' ) {
					validator.error( `'checked' binding can only be used with <input type="checkbox">`, attribute.start );
				}
			}

			else if ( name === 'group' ) {
				if ( node.name !== 'input' ) {
					validator.error( `'group' is not a valid binding on <${node.name}> elements`, attribute.start );
				}

				const type = getType( validator, node );

{'fraction_non_alphanumeric': 0.17556346381969157, 'fraction_numerical': 0.0, 'mean_word_length': 3.2521008403361344, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4537524', 'n_tokens_mistral': 891, 'n_tokens_neox': 774, 'n_words': 226}