How to use the @amalto/helpers.isNotEmpty function in @amalto/helpers

To help you get started, we’ve selected a few @amalto/helpers 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 amalto / platform6-ui-components / components / validated-input / index.tsx View on Github external
private validateField = ( value: string, props: ValidatedInput.Props ) => {
        const emptyButMandatory = !isNotEmpty(value) && !!props.mandatory
        const noMatchRegex = props.regex ? !props.regex.test( value ) : false
        const invalid = props.validate ? !props.validate( value ) : false

        if ( !props.disabled ) {
            this.setState( {
                invalidInput: emptyButMandatory || noMatchRegex || invalid
            }, () => {
                props.handleFieldChange( value, props.name, this.state.invalidInput )
            } )
        }
    }
github amalto / platform6-ui-components / components / multi-select-input / index.tsx View on Github external
private renderMultiSelectInput = ( field: WrappedFieldProps ) => {
        const { label, options, disabled, help, containerClass, inputClass, collapseErrorSpace, fieldLineHeight } = this.props

        const { input, meta } = field

        const extendedStyle: React.CSSProperties = this.getExtendedStyle( fieldLineHeight, input.value )

        const selectValue: string[] = isNotEmpty( input.value ) ? ( input.value as string ).split( ',' ) : []

        let choices = options.map( ( choice, idx ) => {

            let option = choice.label.trim()

            return (
                <li> v.trim() === option ) !== -1 } )}&gt;
                    <a href="#"> this.selectOption( e, field, selectValue, option )}&gt;
                        {option}
                    </a>
                </li>
            )
        } )

        return (
github amalto / platform6-ui-components / components / tree / index.tsx View on Github external
private createNode = () => {
        let { editedNode, wordings } = this.state

        let errors: string[] = []
        if ( isNotEmpty( editedNode.elementName ) ) {
            if ( this.state.selectedNode.data.childNames.indexOf( editedNode.elementName ) !== -1 ) {
                errors.push( wordings.invalidUniqueNodeName )
            }
        }
        else {
            errors.push( wordings.name )
        }

        if ( !isNotEmpty( editedNode.description ) ) {
            errors.push( wordings.description )
        }

        for ( const key in editedNode.propertiesMap ) {
            if ( !key ) {
                errors.push( wordings.propertiesKey )
            }
        }

        if ( errors.length > 0 ) {
            this.props.displayEmptyValsError( errors )
        }
        else {
            this.props.createNode( editedNode.parentId, editedNode.elementName.trim(), editedNode.description, editedNode.propertiesMap )
            this.clearForm()
        }
github amalto / platform6-ui-components / components / service-helpers / index.tsx View on Github external
export function validateName( value: string, id: Id, items: ServiceItemFacades, locale: string ): string {
    const wordings: { [id: string]: string } = compileWordings( MULTILANGUAGE_WORDINGS, locale )

    if ( !isNotEmpty( value ) ) return wordings.fieldRequired

    if ( value !== id.name && !isIdUnique( items, { name: value, appKey: id.appKey } ) )
        return wordings.nameAlreadyExist

    if ( value.includes( '.' ) ) return wordings.nameNoDot
}
github amalto / platform6-ui-components / components / tree / index.tsx View on Github external
private editNode = () => {
        let { editedNode, wordings } = this.state

        let errors: string[] = []
        if ( !isNotEmpty( editedNode.elementName ) ) {
            errors.push( wordings.name )
        }
        if ( !isNotEmpty( editedNode.description ) ) {
            errors.push( wordings.description )
        }

        for ( const key in editedNode.propertiesMap ) {
            if ( !key ) {
                errors.push( wordings.propertiesKey )
            }
        }

        if ( errors.length > 0 ) {
            this.props.displayEmptyValsError( errors )
        }
        else {
github amalto / platform6-ui-components / components / typeahead-input / index.tsx View on Github external
constructor( props: TypeaheadInput.Props ) {
        super( props )

        this.state = {
            typeaheadInputId: `#${this.props.id}_typeahead`,
            shouldDisplayDropdown: isNotEmpty( props.selectedCollectionType ) && !!props.collectionTypes && !!props.setCollectionType
        }
    }
github amalto / platform6-ui-components / components / input-validation / index.tsx View on Github external
export const required = ( value: string, locale: string ) => isNotEmpty( value ) ? undefined : error( 'fieldRequired', locale )
github amalto / platform6-ui-components / components / tree / index.tsx View on Github external
private createNode = () => {
        let { editedNode, wordings } = this.state

        let errors: string[] = []
        if ( isNotEmpty( editedNode.elementName ) ) {
            if ( this.state.selectedNode.data.childNames.indexOf( editedNode.elementName ) !== -1 ) {
                errors.push( wordings.invalidUniqueNodeName )
            }
        }
        else {
            errors.push( wordings.name )
        }

        if ( !isNotEmpty( editedNode.description ) ) {
            errors.push( wordings.description )
        }

        for ( const key in editedNode.propertiesMap ) {
            if ( !key ) {
                errors.push( wordings.propertiesKey )
            }