imports/vx/client/code/ux.js
/**
     * Validate a field either client or server side.
     * Generate popovers and alerts accordingly.
     *
     * @param {object} component Component.
     * @return {object} Result object.
     */
Validate a field either client or server side.
Generate popovers and alerts accordingly.

@param {object} component Component.
@return {object} Result object.
Validate a field either client or server side . Generate popovers and alerts accordingly . @param { object } component Component . @return { object } Result object .
async validateInstance(component) {
        const form = UX.findForm(component.props.id)
        const validateArgs = UX.prepareValidateArgs(component)
        let result = { success: true }
        if (!form) {
            return result
        }
        if (form.props.dynamic && Util.isNullish(validateArgs[0])) {
            if (component.props.required) {
                if (component.props.missingReset) {
                    component.reset()
                }
                return { success : false, icon : "TRIANGLE", key : "common.required_fields_incomplete" }
            }
        }
        else if (!Util.isNullish(validateArgs[0])) {
            if (component.props.rule) {
                if (_.isString(component.props.rule)) {
                    OLog.debug(`ux.js validateInstance invoking server-side rule ${component.props.rule}`)
                    result = await UX.call("validateServerSide", component.props.rule, validateArgs)
                    OLog.debug(`ux.js validateInstance server-side result=${OLog.debugString(result)}`)
                }
                else {
                    result = component.props.rule.apply(component, validateArgs)
                }
            }
        }
        UX.validateFinish(component, validateArgs, result)
        return result
    }
async validateInstance ( component ) { const form = UX . findForm ( component . props . id ) const validateArgs = UX . prepareValidateArgs ( component ) let result = { success : true } if ( ! form ) { return result } if ( form . props . dynamic && Util . isNullish ( validateArgs [ 0 ] ) ) { if ( component . props . required ) { if ( component . props . missingReset ) { component . reset ( ) } return { success : false , icon : "TRIANGLE" , key : "common.required_fields_incomplete" } } } else if ( ! Util . isNullish ( validateArgs [ 0 ] ) ) { if ( component . props . rule ) { if ( _ . isString ( component . props . rule ) ) { OLog . debug ( ` ${ component . props . rule } ` ) result = await UX . call ( "validateServerSide" , component . props . rule , validateArgs ) OLog . debug ( ` ${ OLog . debugString ( result ) } ` ) } else { result = component . props . rule . apply ( component , validateArgs ) } } } UX . validateFinish ( component , validateArgs , result ) return result }
Validate a field either client or server side.
Validate a field either client or server side .