JSON VALIDATION

  • Fieldy Application handle the validation by containing a common JSON file

  • The JSON file have been separated my module wise
  • The json file have containing a global validation rules.
  • In default the global rules should applicable for the whole fieldy application,untill the fieldy customer customizing their own rules
  • Initially the global rules json file have been stored in database.
  • When the customers ( tenants ) will customizing the global rules the customized rules will be stored under the customers .(tenants)
  • Whenever the validation part will execute, will check if customers (tenants ) have an own validation rules or not, if they have own rules, it wil validate the forms based on that. Other wise the global rules should work for all the validation
  • List of modules JSON File

JSON FORMAT

Notes :

Modules - quote,invoice,inventory the first object should be form name . here the module name doesn't came.

  • The JSON format containing a first object as module name
  • The JSON format containing a second object as form name. it means it indicate in the modules which form we are going to validate the data request.
  • The Json param are formed based on API request input
  • List of param types we formed in the Json file
    • string
    • number
    • creatable
    • file
    • dropdown
    • date
    • time
    • json
    • decimal
    • email

Params Type Description

String

  • It will contain totally 7 objects
  • 1 .type
    • it indicate which type of params it is
    2.maximum_characters
    • it indicate the param should accept maximum of how many characters. including empty spaces.
    • The value should be in integer
    3.minimum_characters
    • it indicate the param should accept minimum of how many characters. including empty spaces.
    4.special_characters_allowed
    • it indicate the param what are all the special character accepting
    • The special characters are formatted as unique codes
    5.special_characters_restricted
    • it indicate the param what are all the special character not allowed.
    • The special characters are formatted as unique codes
    6.is_required
    • it indicate whether it is mandatory or optional.
    • The value is true as considered as mandatory
    • The value is false as considered as optional
    7.is_unique
    • it indicate whether it is unique param.
    • The value is true as considered as unique
    • The value is false as considered as not a unique

    Sample Format


    
        "first_name":{
                    "type":"string",
                    "maximum_characters":256,
                    "minimum_characters":1,
                    "special_characters_allowed":[
                        "all"
                    ],
                    "special_characters_restricted":[
    
                    ],
                    "is_unique":false,
                    "is_required":true
                },
    
    

email

  • It will contain totally 7 objects
  • 1 .type
    • it indicate which type of params it is
    2.maximum_characters
    • it indicate the param should accept maximum of how many characters. including empty spaces.
    • The value should be in integer
    3.minimum_characters
    • it indicate the param should accept minimum of how many characters. including empty spaces.
    4.special_characters_allowed
    • it indicate the param what are all the special character accepting
    • The special characters are formatted as unique codes
    5.special_characters_restricted
    • it indicate the param what are all the special character not allowed.
    • The special characters are formatted as unique codes
    6.is_required
    • it indicate whether it is mandatory or optional.
    • The value is true as considered as mandatory
    • The value is false as considered as optional
    7.is_unique
    • it indicate whether it is unique param.
    • The value is true as considered as unique
    • The value is false as considered as not a unique

Sample Format



    "email":{
                "type":"email",
                "maximum_characters":256,
                "minimum_characters":0,
                "special_characters_allowed":[
                    "all"
                ],
                "special_characters_restricted":[

                ],
                "is_unique":true,
                "is_required":false
            },

Number

  • It will contain totally 9 objects
  • 1 .type
    • it indicate which type of params it is
    2.is_decimal
    • it indicate the param should accept decimal values
    3.maximum_digits
    • it indicate the param should accept maximum of how many digits. including empty spaces.
    • The value should be in integer
    4.maximum_digits_with_decimal_point
    • it indicate the param should accept maximum of how many digits with decimal values. including empty spaces.
    5.minimum_digit
    • it indicate the param should accept minimum of how many digits. including empty spaces.
    6.special_characters_allowed
    • it indicate the param what are all the special character accepting
    • The special characters are formatted as unique codes
    7.special_characters_restricted
    • it indicate the param what are all the special character not allowed.
    • The special characters are formatted as unique codes
    8.is_required
    • it indicate whether it is mandatory or optional.
    • The value is true as considered as mandatory
    • The value is false as considered as optional
    9.is_unique
    • it indicate whether it is unique param.
    • The value is true as considered as unique
    • The value is false as considered as not a unique

    Sample Format


    
        "number":{
                                "type":"number",
                                "is_decimal":false,
                                "minimum_digit":6,
                                "maximum_digits":12,
                                "maximum_digits_with_decimal_point":null,
                                "special_characters_allowed":[
    
                                ],
                                "special_characters_restricted":[
    
                                ],
                                "is_required":false,
                                "is_unique":false
                            }
    
    

    Decimal

    • It will contain totally 9 objects
    • 1 .type
      • it indicate which type of params it is
      2.is_decimal
      • it indicate the param should accept decimal values
      3.maximum_characters
      • it indicate the param should accept maximum of how many characters. including empty spaces.
      • The value should be in integer
      4.minimum_characters
      • it indicate the param should accept minimum of how many characters. including empty spaces.
      5.maximum_before_point
      • it indicate the param should accept maximum of how many characters. including empty spaces.
      • The value should be in integer
      6.maximum_after_point
      • it indicate the param should accept minimum of how many characters. including empty spaces.
      7.special_characters_allowed
      • it indicate the param what are all the special character accepting
      • The special characters are formatted as unique codes
      8.special_characters_restricted
      • it indicate the param what are all the special character not allowed.
      • The special characters are formatted as unique codes
      9.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional
      10.is_unique
      • it indicate whether it is unique param.
      • The value is true as considered as unique
      • The value is false as considered as not a unique

    Sample Format


    
       "quantity":{
                            "type":"decimal",
                            "is_required":true,
                            "is_unique":false,
                            "special_characters_allowed":[
    
                            ],
                            "special_characters_restricted":[
    
                            ],
                            "maximum_characters":15,
                            "minimum_characters":1,
                            "maximum_before_point":12,
                            "maximum_after_point":2,
                            "maximum_value":"999999999999.99"
                        },
    
    

    createble

    • It will contain totally 7 objects
    • 1 .type
      • it indicate which type of params it is
      2.maximum_characters
      • it indicate the param should accept maximum of how many characters. including empty spaces.
      • The value should be in integer
      3.minimum_characters
      • it indicate the param should accept minimum of how many characters. including empty spaces.
      4.special_characters_allowed
      • it indicate the param what are all the special character accepting
      • The special characters are formatted as unique codes
      5.special_characters_restricted
      • it indicate the param what are all the special character not allowed.
      • The special characters are formatted as unique codes
      6.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional
      7.is_unique
      • it indicate whether it is unique param.
      • The value is true as considered as unique
      • The value is false as considered as not a unique

    Sample Format


    
        "id_customer_group":{
                "type":"creatable",
                "maximum_characters":256,
                "minimum_characters":0,
                "special_characters_allowed":[
                    "all"
                ],
                "special_characters_restricted":[
    
                ],
                "is_required":false,
                "is_unique":false
            },
    
    

    file

    • It will contain totally 5 objects
    • 1 .type
      • it indicate which type of params it is
      2.is_multiple_upload
      • Whether the param should accept multiple files or not
      3.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional
      3.allowed_formats
      • What are all the file format it should accept
      4.maximum_upload_size
      • Maximum how many size it should accept the file

    Sample Format


    
         "company_logo":{
                    "type":"file",
                    "is_multiple_upload":false,
                    "is_required":false,
                    "maximum_files_upload":null,
                    "allowed_formats":[
                        "jpg",
                        "jpeg",
                        "png"
                    ],
                    "maximum_upload_size":2048
                },
    
    

    dropdown

    • It will contain totally 7 objects
    • 1 .type
      • it indicate which type of params it is
      2.maximum_characters
      • it indicate the param should accept maximum of how many characters. including empty spaces.
      • The value should be in integer
      3.minimum_characters
      • it indicate the param should accept minimum of how many characters. including empty spaces.
      4.special_characters_allowed
      • it indicate the param what are all the special character accepting
      • The special characters are formatted as unique codes
      5.special_characters_restricted
      • it indicate the param what are all the special character not allowed.
      • The special characters are formatted as unique codes
      6.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional
      7.is_hardcoded
      • it indicate whether the dropdown values are hardcoded or dynamic values
      8.valid_inputs
      • If values are hardcoded, here we need to provide a list of values
      9.default_value
      • The param have any default value, we need to provide here

    Sample Format


    
        "status":{
                    "type":"dropdown",
                    "is_hardcoded":true,
                    "default_value":"active",
                    "valid_inputs":[
                        "active",
                        "inactive"
                    ],
                    "maximum_characters":64,
                    "minimum_characters":0,
                    "special_characters_allowed":[
    
                    ],
                    "special_characters_restricted":[
    
                    ],
                    "is_required":true
                },
    
    

    date

    • It will contain totally 7 objects
    • 1 .type
      • it indicate which type of params it is
      2.maximum_value
      • it indicate the param should accept maximum value
      3.minimum_value
      • it indicate the param should accept minimum of value
      4.special_characters_allowed
      • it indicate the param what are all the special character accepting
      • The special characters are formatted as unique codes
      5.special_characters_restricted
      • it indicate the param what are all the special character not allowed.
      • The special characters are formatted as unique codes
      6.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional

    Sample Format


    
       "date_installed":{
                                "type":"date",
                                "maximum_value":"current_date",
                                "minimum_value":"1970-01-01",
                                "special_characters_allowed":[
                                    "U+002D",
                                    "U+002F",
                                    "U+003A"
                                ],
                                "special_characters_restricted":[
    
                                ],
                                "is_required":false
                            },
    
    

    time

    • It will contain totally 7 objects
    • 1 .type
      • it indicate which type of params it is
      2.format
      • it indicate which format the param accept
      3.special_characters_allowed
      • it indicate the param what are all the special character accepting
      • The special characters are formatted as unique codes
      4.special_characters_restricted
      • it indicate the param what are all the special character not allowed.
      • The special characters are formatted as unique codes
      5.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional

    Sample Format


    
       "schedule_from_time": {
                    "type": "time",
                    "format": "H:i",
                    "is_required": false,
                    "special_characters_allowed": [],
                    "special_characters_restricted":[]
                },
    
    

    JSON

    • It will contain totally 7 objects
    • 1 .type
      • it indicate which type of params it is
      2.is_required
      • it indicate whether it is mandatory or optional.
      • The value is true as considered as mandatory
      • The value is false as considered as optional
      3.minimum_count
      • minimum of how many object count it should accept
      4.maximum_count
      • maximum of how many object count it should accept
      5.fields name (param request fields name)
      • It is an array format
      • Inside the array we have an fields name object. The object contain what are all the params we are gonna send in the array fields

    Sample Format


    
       "tags": {
                    "type": "json",
                    "is_required": false,
                    "minimum_count": 0,
                    "maximum_count": 64,
                    "tags": [
                        {
                            "tags": {
                                "type": "string",
                                "maximum_characters": 256,
                                "minimum_characters": 1,
                                "special_characters_allowed": [
                                    "all"
                                ],
                                "special_characters_restricted":[],
                                "is_unique": false,
                                "is_required": true
                            }
                        }
                    ]
                }