<commit_before>import { inIPRange, isIP, isCIDR } from '@terascope/utils';
import { FieldType } from '@terascope/types';

import {
    FieldValidateConfig, ProcessMode, FunctionDefinitionType, FunctionDefinitionCategory
} from '../interfaces';

interface InIPRangeArgs {
    min?: string;
    max?: string;
    cidr?: string;
}

export const inIPRangeConfig: FieldValidateConfig = {
    name: 'inIPRange',
    type: FunctionDefinitionType.FIELD_VALIDATION,
    process_mode: ProcessMode.INDIVIDUAL_VALUES,
    category: FunctionDefinitionCategory.IP,
    examples: [
        {
            args: { cidr: '8.8.8.0/24' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: '8.8.8.8',
            output: '8.8.8.8',
        },
        {
            args: { min: 'fd00::123', max: 'fd00::ea00' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: 'fd00::b000',
            output: 'fd00::b000',
        },
        {
            args: { min: 'fd00::123' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: 'fd00::b000',
            output: 'fd00::b000',
        },
        {
            args: { cidr: '8.8.8.0/24' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: '8.8.10.8',
            output: null,
        }
    ],
    description: 'Checks if the ip is within a range, inclusive.  Accepts min, max or cidr notation for the ip range.  Function accepts min without a max and vice versa.',
    create(args: InIPRangeArgs) {
        return (input: unknown) => inIPRange(input, args);
    },
    accepts: [FieldType.String, FieldType.IPRange],
    argument_schema: {
        min: {
            type: FieldType.String,
            description: 'IPv4 or IPv6 value, used for the bottom of the range'
        },
        max: {
            type: FieldType.String,
            description: 'IPv4 or IPv6 value, used for the top of the range'<commit_msg>inIPRange should just accept an IP<commit_after>import { inIPRange, isIP, isCIDR } from '@terascope/utils';
import { FieldType } from '@terascope/types';

import {
    FieldValidateConfig, ProcessMode, FunctionDefinitionType, FunctionDefinitionCategory
} from '../interfaces';

interface InIPRangeArgs {
    min?: string;
    max?: string;
    cidr?: string;
}

export const inIPRangeConfig: FieldValidateConfig = {
    name: 'inIPRange',
    type: FunctionDefinitionType.FIELD_VALIDATION,
    process_mode: ProcessMode.INDIVIDUAL_VALUES,
    category: FunctionDefinitionCategory.IP,
    examples: [
        {
            args: { cidr: '8.8.8.0/24' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: '8.8.8.8',
            output: '8.8.8.8',
        },
        {
            args: { min: 'fd00::123', max: 'fd00::ea00' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: 'fd00::b000',
            output: 'fd00::b000',
        },
        {
            args: { min: 'fd00::123' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: 'fd00::b000',
            output: 'fd00::b000',
        },
        {
            args: { cidr: '8.8.8.0/24' },
            config: { version: 1, fields: { testField: { type: FieldType.String } } },
            field: 'testField',
            input: '8.8.10.8',
            output: null,
        }
    ],
    description: 'Checks if the ip is within a range, inclusive.  Accepts min, max or cidr notation for the ip range.  Function accepts min without a max and vice versa.',
    create(args: InIPRangeArgs) {
        return (input: unknown) => inIPRange(input, args);
    },
    accepts: [FieldType.String, FieldType.IP],
    argument_schema: {
        min: {
            type: FieldType.String,
            description: 'IPv4 or IPv6 value, used for the bottom of the range'
        },
        max: {
            type: FieldType.String,
            description: 'IPv4 or IPv6 value, used for the top of the range'
{'fraction_non_alphanumeric': 0.13157894736842105, 'fraction_numerical': 0.030399274047186932, 'mean_word_length': 2.0618055555555554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, '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': '6342100', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1348, 'n_words': 352}