<commit_before>/* jshint globalstrict: true */
'use strict';

var React                      = require('react');
var classSet                   = require('react/lib/cx');
var SynfrastructureHelperMixin = require('../../../mixins/synfrastructure-helper-mixin');

module.exports = React.createClass({

    displayName : 'UI-Validation',

    mixins : [SynfrastructureHelperMixin],

    propTypes : {
        componentCSSClassName : React.PropTypes.string,
        renderMessages        : React.PropTypes.oneOf(['before', 'after']),
        messageContainer      : React.PropTypes.func,
        messageContainerProps : React.PropTypes.object,
        validation : React.PropTypes.shape({
            status   : React.PropTypes.string,
            messages : React.PropTypes.array
        })
    },

    getDefaultProps : function()
    {
        return {
            componentCSSClassName : 'validation',
            renderMessages        : 'after',
            messageContainer      : null,
            messageContainerProps : null,
            validation            : null
        };
    },

    renderValidationMessages : function()
    {
        var messages     = [],
            component    = this,
            messageProps = {},
            messageElement,
            messageClasses;

        if (! this.props.validation) {
            return null;
        }

        messageElement = this.props.messageContainer ?
            this.props.messageContainer : 'div';

        this.props.validation.messages.map(function(message, index) {
            messageClasses = [
                component.props.componentCSSClassName + '__message',
                component.props.componentCSSClassName + '__message--' + component.props.validation.status
            ].join(' ');

            messageProps = {
                className : messageClasses,
                key       : 'validation-msg-' + index
            };

            messages.push(
                React.createElement(
                    messageElement,<commit_msg>update validation check<commit_after>/* jshint globalstrict: true */
'use strict';

var React                      = require('react');
var classSet                   = require('react/lib/cx');
var SynfrastructureHelperMixin = require('../../../mixins/synfrastructure-helper-mixin');

module.exports = React.createClass({

    displayName : 'UI-Validation',

    mixins : [SynfrastructureHelperMixin],

    propTypes : {
        componentCSSClassName : React.PropTypes.string,
        renderMessages        : React.PropTypes.oneOf(['before', 'after']),
        messageContainer      : React.PropTypes.func,
        messageContainerProps : React.PropTypes.object,
        validation : React.PropTypes.shape({
            status   : React.PropTypes.string,
            messages : React.PropTypes.array
        })
    },

    getDefaultProps : function()
    {
        return {
            componentCSSClassName : 'validation',
            renderMessages        : 'after',
            messageContainer      : null,
            messageContainerProps : null,
            validation            : null
        };
    },

    renderValidationMessages : function()
    {
        var messages     = [],
            component    = this,
            messageProps = {},
            messageElement,
            messageClasses;

        if (! this.props.validation || ! this.props.validation.messages) {
            return null;
        }

        messageElement = this.props.messageContainer ?
            this.props.messageContainer : 'div';

        this.props.validation.messages.map(function(message, index) {
            messageClasses = [
                component.props.componentCSSClassName + '__message',
                component.props.componentCSSClassName + '__message--' + component.props.validation.status
            ].join(' ');

            messageProps = {
                className : messageClasses,
                key       : 'validation-msg-' + index
            };

            messages.push(
                React.createElement(
                    messageElement,
{'fraction_non_alphanumeric': 0.10292682926829268, 'fraction_numerical': 0.0, 'mean_word_length': 1.7105089226701917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5315290', 'n_tokens_mistral': 982, 'n_tokens_neox': 943, 'n_words': 172}