Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example provided does not work when insert validation #67

Open
guiihlopes opened this issue Aug 27, 2019 · 4 comments
Open

Example provided does not work when insert validation #67

guiihlopes opened this issue Aug 27, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@guiihlopes
Copy link

Describe the bug

Hello!

Using the example provided and inserting any simple validation it's not working... I check it out and I have discovered that its always dispatching error when there's a nested field like attributes.title or attributes[title], when the field name is title only the validation works without any problem. It seems not validating with the current value!

To Reproduce

1: https://github.com/flipbyte/formik-json-schema#prepare-your-form-object
2: Add simple string required validation.

Expected behavior

It expected to show error only when field is empty.

image
image

@guiihlopes guiihlopes added the bug Something isn't working label Aug 27, 2019
@easeq
Copy link
Collaborator

easeq commented Aug 31, 2019

It seems to be working fine in the demo containers example: https://flipbyte.github.io/formik-json-schema/#containers. The only difference i could see in your schema and that of the example is the the error message "Required field". Can you try without that and see whether it's working?

@guiihlopes
Copy link
Author

It seems to be working fine in the demo containers example: https://flipbyte.github.io/formik-json-schema/#containers. The only difference i could see in your schema and that of the example is the the error message "Required field". Can you try without that and see whether it's working?

@easeq It still not working as showed in next images...

image

image

If you would like to reproduce, use this schema provided with the addition of validation:

            id: "my-new-form",
            label: "My New Form",
            type: "container",
            renderer: "form",
            elements: {
                save: {
                    type: "field",
                    renderer: "button",
                    name: "save",
                    label: "Save",
                    htmlClass: "btn-success",
                    buttonType: "submit"
                },
                main: {
                    type: "container",
                    renderer: "div",
                    htmlClass: "row",
                    elements: {
                        title: {
                            name: "title",
                            label: "Title",
                            type: "field",
                            renderer: "text",
                            fieldType: "text",
                            validation: [['string'], ['required']]

                        },
                        title1: {
                            name: "attributes.0.title1",
                            label: "Title 1",
                            type: "field",
                            renderer: "text",
                            fieldType: "text",
                            validation: [['string'], ['required']]
                        },
                    }
                },
            }
        }

@easeq
Copy link
Collaborator

easeq commented Aug 31, 2019

Which version of formik-json are you using? Also, try this:

fieldset: {
    type: 'container',
    renderer: 'fieldset',
    title: ' Simple Fieldset',
    name: 'attributes',
    elements: {
        title: {
            name: 'title',
            label: 'Title 1',
            type: 'field',
            renderer: 'text',
            fieldType: 'text',
            validation: [
                ['string'],
                ['required'],
            ]
        }
    }
},

@guiihlopes
Copy link
Author

guiihlopes commented Aug 31, 2019

Im using the latest published in npm,"^0.4.0".

When I use a simple element name attribute like title it works normally, but the problem I said is when I try to use a nested field name like attributes.0.title1 it not works as expected with validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants