<commit_before>import * as React from 'react';

import formElement, { FormElementProps } from '../../forms/FormElement';
import { lineBreak } from 'acorn';
import ErrorMessages from '../../forms/errors/ErrorMessages';
import Message from '../../forms/errors/Message';

export interface TextInputProps extends FormElementProps {
    minLength?: number,
}

class TextInput extends React.Component<TextInputProps, {}> {
    render() {
        const {
            onChange = () => { },
            value = '',
            errors,
            minLength
        } = this.props;


        return (
            <>
                <input
                    type="text"
                    value={value}
                    onChange={(e) => onChange(e.target.value)}
                />
                <ErrorMessages errors={errors}>
                    <ul>
                        <Message errorKey="required"><li>This value is required.</li></Message>
                        <Message errorKey="minLength"><li>This value must be at least {minLength} characters long.</li></Message>
                    </ul>
                </ErrorMessages>
            </>
        )
    }
}

export default formElement({
    validators: {
        required: (props: TextInputProps) => {
            if (!props.required) {
                return true;
            }

            return props.value !== null && props.value !== undefined && props.value.trim() !== '';
        },
        minLength: ({ minLength, value }: TextInputProps) => {
            if (minLength === undefined || minLength <= 0) {
                return true;
            }

            if (value === undefined) {
                return false;
            }


            return value.length >= minLength;
        }
    }
})(TextInput);<commit_msg>Accidental import<commit_after>import * as React from 'react';

import formElement, { FormElementProps } from '../../forms/FormElement';
import ErrorMessages from '../../forms/errors/ErrorMessages';
import Message from '../../forms/errors/Message';

export interface TextInputProps extends FormElementProps {
    minLength?: number,
}

class TextInput extends React.Component<TextInputProps, {}> {
    render() {
        const {
            onChange = () => { },
            value = '',
            errors,
            minLength
        } = this.props;


        return (
            <>
                <input
                    type="text"
                    value={value}
                    onChange={(e) => onChange(e.target.value)}
                />
                <ErrorMessages errors={errors}>
                    <ul>
                        <Message errorKey="required"><li>This value is required.</li></Message>
                        <Message errorKey="minLength"><li>This value must be at least {minLength} characters long.</li></Message>
                    </ul>
                </ErrorMessages>
            </>
        )
    }
}

export default formElement({
    validators: {
        required: (props: TextInputProps) => {
            if (!props.required) {
                return true;
            }

            return props.value !== null && props.value !== undefined && props.value.trim() !== '';
        },
        minLength: ({ minLength, value }: TextInputProps) => {
            if (minLength === undefined || minLength <= 0) {
                return true;
            }

            if (value === undefined) {
                return false;
            }


            return value.length >= minLength;
        }
    }
})(TextInput);
{'fraction_non_alphanumeric': 0.13072814169243746, 'fraction_numerical': 0.000562271577171774, 'mean_word_length': 1.4708333333333334, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 45, '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': '5388626', 'n_tokens_mistral': 880, 'n_tokens_neox': 845, 'n_words': 202}