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

Validation not working after generating the build #2020

Closed
2 of 3 tasks
jitdwoodside opened this issue Aug 28, 2020 · 12 comments
Closed
2 of 3 tasks

Validation not working after generating the build #2020

jitdwoodside opened this issue Aug 28, 2020 · 12 comments
Labels
possibly close To confirm if this issue can be closed

Comments

@jitdwoodside
Copy link

jitdwoodside commented Aug 28, 2020

Prerequisites

Description

The validation is working fine in local but after generating production build it is showing error. Here is the error

Error compiling schema, function code: var refVal1 = refVal[1]; var validate = function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; var vErrors = null; var errors = 0; if (rootData === undefined) rootData = data; var errs_1 = errors; var errs_2 = errors; if ((typeof data !== "number" || (data % 1) || data !== data)) { var err = { keyword: 'type' , dataPath: (dataPath || '') + "" , schemaPath: '#/definitions/nonNegativeInteger/type' , params: { type: 'integer' } , message: 'should be integer' } ; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } if ((typeof data === "number")) { if ( data < 0 || data !== data) { var err = { keyword: 'minimum' , dataPath: (dataPath || '') + "" , schemaPath: '#/definitions/nonNegativeInteger/minimum' , params: { comparison: '>=', limit: 0, exclusive: false } , message: 'should be >= 0' } ; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } var valid2 = errors === errs_2; var valid1 = errors === errs_1; validate.errors = vErrors; return errors === 0; }; return validate;

Steps to Reproduce

const schema: JSONSchema7 = {
        "type": "object",
        "required": [
            "firstName"
        ],
        "properties": {
            "firstName": {
                "type": "string",
                "title": 'First Name',
                "minLength": 5
            }
        }
};

const uiSchema = {
        "firstName": {
            "ui:options": {
                label: false
            }
        }
 };
const formData = {
        firstName: ""
};

Expected behavior

The validation should work and show error message

Actual behavior

Showing error:-
Error compiling schema, function code: var refVal1 = refVal[1]; var validate = function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; var vErrors = null; var errors = 0; if (rootData === undefined) rootData = data; var errs_1 = errors; var errs_2 = errors; if ((typeof data !== "number" || (data % 1) || data !== data)) { var err = { keyword: 'type' , dataPath: (dataPath || '') + "" , schemaPath: '#/definitions/nonNegativeInteger/type' , params: { type: 'integer' } , message: 'should be integer' } ; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } if ((typeof data === "number")) { if ( data < 0 || data !== data) { var err = { keyword: 'minimum' , dataPath: (dataPath || '') + "" , schemaPath: '#/definitions/nonNegativeInteger/minimum' , params: { comparison: '>=', limit: 0, exclusive: false } , message: 'should be >= 0' } ; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } var valid2 = errors === errs_2; var valid1 = errors === errs_1; validate.errors = vErrors; return errors === 0; }; return validate;

Version

I am using "@rjsf/core": "^2.3.0"

@epicfaace
Copy link
Member

Does this error only happen with that specific schema? Or with even a simple schema such as {type: "string"}?

@jitdwoodside
Copy link
Author

Yes the issue is also happening for simple schema {type: "string"}

@jitdwoodside
Copy link
Author

FYI i am using typescript to write the code.

@jitdwoodside
Copy link
Author

Hi There,

Any update on this issue?

@VivianaG
Copy link

VivianaG commented Oct 7, 2020

Hi,

I also ran into the same issue. After debugging it, it seems that it might relate to this issue actually: ajv-validator/ajv#551

@PremVarma
Copy link

If you are using helmet in react please use version 3.22.0 it internally has helmet-csp which solved this contect Security Policy issue or you can seprately install helmet-csp from npm.

@BALEHOK
Copy link

BALEHOK commented Mar 23, 2022

@jitdwoodside I understand this is an old post, but have you solved the problem and how? Thanks.

@jainamshah711
Copy link

@jitdwoodside have you find anything to resolve the above issue?

@heath-freenome
Copy link
Member

So the fix for this is NOT really in @rjsf per this comment in AJV

@nickgros
Copy link
Contributor

nickgros commented Dec 9, 2022

This could be a potential path forward: #3269

Copy link

stale bot commented Mar 9, 2024

This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

@stale stale bot added the possibly close To confirm if this issue can be closed label Mar 9, 2024
Copy link

stale bot commented Apr 10, 2024

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

@stale stale bot closed this as completed Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possibly close To confirm if this issue can be closed
Projects
None yet
Development

No branches or pull requests

8 participants