How to use the kpc/components/form.Form.addMethod function in kpc

To help you get started, we’ve selected a few kpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ksc-fe / kpc / components / form / demos / custom / index.jsx View on Github external
import React from 'react';
import {Form, FormItem} from 'kpc/components/form';
import {Input} from 'kpc/components/input';
import {Button} from 'kpc/components/button';
import './index.styl';

// 添加全局规则
Form.addMethod('letter', (value, item, param) => {
    return /^[a-z|A-Z]+$/.test(value);
}, '只能输入字母');

export default class Demo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            "descriptions": [
                "",
                ""
            ]
        };
        this._onChangeValue = this._onChangeValue.bind(this);
        this.add = this.add.bind(this);
        this.remove = this.remove.bind(this);
    }
github ksc-fe / kpc / components / form / demos / custom / index.js View on Github external
export {default as data} from './index.json';
import Intact from 'intact';
import template from './index.vdt';
import './index.styl'; 

import {Form} from 'kpc/components/form';

// 添加全局规则
Form.addMethod('letter', (value, item, param) => {
    return /^[a-z|A-Z]+$/.test(value);
}, '只能输入字母');

export default class extends Intact {
    @Intact.template()
    static template = template;

    defaults() {
        return {
            descriptions: ['', '']
        }
    }

    add() {
        this.set('descriptions', this.get('descriptions').concat(''));
    }