<commit_before>import * as React from 'react'
import {Input} from 'react-bootstrap'
import {inRange, isIP4Cidr, isIP6CIDR, isInt} from '../util/simple-validators'

export var NetworkForm = React.createClass({

    getValues() {
        return this.state;
    },

    validate() {
        var errors = [];
        var data = this.state
        if (!data['description']) {errors.push('Description is missing')};
        if (!data['vlan']) {errors.push('Vlan is missing')};
        if (data['vlan'] && !inRange(data['vlan'], 0, 4096)) {
            errors.push('Vlan must be a number 0-4096')
        };
        if (data['prefix4'] && !isIP4Cidr(data['prefix4'])) {
            errors.push('IPv4 prefix is invalid')
        };
        if (data['prefix6'] && !isIP6Cidr(data['prefix6'])) {
            errors.push('IPv6 prefix is invalid')
        };
        if (!data['max_lease']) {errors.push('Max. lease is missing')};
        if (data['max_lease'] && !isInt(data['max_lease'])) {
            errors.push('Max. lease must be a number')<commit_msg>Fixed broken ipv6 validation in network form<commit_after>import * as React from 'react'
import {Input} from 'react-bootstrap'
import {inRange, isIP4Cidr, isIP6Cidr, isInt} from '../util/simple-validators'

export var NetworkForm = React.createClass({

    getValues() {
        return this.state;
    },

    validate() {
        var errors = [];
        var data = this.state
        if (!data['description']) {errors.push('Description is missing')};
        if (!data['vlan']) {errors.push('Vlan is missing')};
        if (data['vlan'] && !inRange(data['vlan'], 0, 4096)) {
            errors.push('Vlan must be a number 0-4096')
        };
        if (data['prefix4'] && !isIP4Cidr(data['prefix4'])) {
            errors.push('IPv4 prefix is invalid')
        };
        if (data['prefix6'] && !isIP6Cidr(data['prefix6'])) {
            errors.push('IPv6 prefix is invalid')
        };
        if (!data['max_lease']) {errors.push('Max. lease is missing')};
        if (data['max_lease'] && !isInt(data['max_lease'])) {
            errors.push('Max. lease must be a number')
{'fraction_non_alphanumeric': 0.17223529411764707, 'fraction_numerical': 0.019294117647058823, 'mean_word_length': 2.7102966841186737, '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': '6433348', 'n_tokens_mistral': 681, 'n_tokens_neox': 668, 'n_words': 163}