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

Validations accepting parameters like max, size etc, their parameters gets ignored #162

Open
kubre opened this issue May 30, 2020 · 2 comments

Comments

@kubre
Copy link
Contributor

kubre commented May 30, 2020

Environment:

  • Laravel-Code-Generator Version: 2.4
  • Laravel Version: 7.13

Description:

Validation rules accepting parameters like max, size etc, their parameters gets ignored, as ex. if validation rule max:255 is given resource file will only get max as validation rule. though it only affects resource file as if you have max:255 in resource file then generate the rules it will reflect as expected.

Steps/Commands To Reproduce:

php artisan create:scaffold School --fields="id,name:name;validation:required|string|max:200,name:logo;html-type:file;validation:required|image|max:512,name:contact;validation:required|numeric|max:20,name:address;html-type:textarea;validation:required|string|max:500;data-type-params:500,name:prinicipal;validation:required|string|max:100,name:email;html-type:email;required|email|max:100" --with-migration --with-form-request --with-auth

Content Of The Resource-File:

{
    "fields": [{
            "name": "id",
            "labels": "Id",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": false,
            "is-on-show": false,
            "is-on-form": false,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": true,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": true,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter id here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "id",
            "is-api-visible": true,
            "api-description": "The id of the model."
        },
        {
            "name": "name",
            "labels": "Name",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|string|max|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [
                255
            ],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": true,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter name here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "name",
            "is-api-visible": true,
            "api-description": "The name of the model."
        },
        {
            "name": "logo",
            "labels": "Logo",
            "html-type": "file",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|image|max|file",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": {},
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "logo",
            "is-api-visible": true,
            "api-description": "The logo of the model."
        },
        {
            "name": "contact",
            "labels": "Contact",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|numeric|max|string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter contact here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "contact",
            "is-api-visible": true,
            "api-description": "The contact of the model."
        },
        {
            "name": "address",
            "labels": "Address",
            "html-type": "textarea",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|string|max|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [
                500
            ],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": {},
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "address",
            "is-api-visible": true,
            "api-description": "The address of the model."
        },
        {
            "name": "prinicipal",
            "labels": "Prinicipal",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|string|max|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter prinicipal here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "prinicipal",
            "is-api-visible": true,
            "api-description": "The prinicipal of the model."
        },
        {
            "name": "email",
            "labels": "Email",
            "html-type": "email",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter email here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "email",
            "is-api-visible": true,
            "api-description": "The email of the model."
        }
    ],
    "relations": [],
    "indexes": [],
    "auto-manage-created-and-updated-at": true,
    "table-name": null,
    "protection": {
        "is-model-protected": false,
        "is-controller-protected": false,
        "is-api-resource-protected": false,
        "is-api-resource-collection-protected": false,
        "is-api-documentation-protected": false,
        "is-api-documentation-controller-protected": false,
        "is-form-request-protected": false,
        "is-languages-protected": false,
        "is-form-view-protected": false,
        "is-index-view-protected": false,
        "is-create-view-protected": false,
        "is-edit-view-protected": false,
        "is-show-view-protected": false
    },
    "api-documentation": {
        "access_token_with_bearer": "The access token prefixed with the \"Bearer \" key word.",
        "index_route_description": "Retrieve existing schools.",
        "index_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
        "the_key_is_the_model_property_and_the_value_is_the_model_value": "The array's key is the school property name where the value is the assigned value to the retrieved school.",
        "link_to_retrieve_first_page": "Link to retrieve first page.",
        "link_to_retrieve_last_page": "Link to retrieve last page.",
        "link_to_retrieve_previous_page": "Link to retrieve previous page.",
        "link_to_retrieve_next_page": "Link to retrieve next page.",
        "the_number_of_current_page": "The number of current page.",
        "the_index_of_the_first_retrieved_item": "The index of first retrieved school.",
        "the_number_of_the_last_page": "The number of the last page.",
        "the_base_link_to_the_resource": "The base link to the api resource.",
        "the_number_of_models_per_page": "The number of schools per page.",
        "the_index_of_the_last_retrieved_item": "The index of last retrieved school.",
        "the_total_of_available_pages": "The total of the available pages.",
        "store_route_description": "Create new school.",
        "store_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
        "update_route_description": "Update existsing school.",
        "update_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
        "show_route_description": "Retrieve existsing school.",
        "show_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
        "the_id_of_model_to_retrieve": "The unique id of the school to retrieve",
        "destroy_route_description": "Delete existsing school.",
        "destroy_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
        "the_id_of_model_to_delete": "The id of the school to delete.",
        "general_description": "Allows you to list, create, edit, show and delete schools.",
        "indicate_whether_the_request_was_successful_or_not": "Indicate whether the request was successful or not.",
        "the_id_of_the_model": "The id of the school.",
        "this_parameter_must_be_present_in_the_request": "This parameter must be present in the request.",
        "the_request_failed_validation": "The request failed validation.",
        "list_of_the_invalid_errors": "List of the invalid errors.",
        "the_requested_model_does_not_exists": "The requested school does not exists.",
        "the_user_does_not_have_permission_to_access_the_requested_resource": "User does not have permission to access the requested resource."
    }
}
@weppami
Copy link

weppami commented Jun 12, 2020

Same setup, same problem

@Roham0010
Copy link

I wonder why this is not fixed 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants