USAGE

Foreach file (xlsx, csv, ods, etc) you should define an object with some fixed properties.

  • Spreadsheet Properties
  • Column properties

Spreadsheet Properties

minColumns: (optional) an integer with the maimun columns on the spreadsheet.

maxColumns: (optional) an integer with the minimun columns on the srpreadsheet

hasHeader: (optional) if true, the first row is ignored.

ignoreFirstRowInvalid: (optional) if true, the first row will be ignored if one of the column properties “breaks”.

fieldDelimiter: (optional) a string wich defines which character is separating de CSV, if the import file is a CSV.

Column properties

Defining the columns

position: (requierd) an integer with the column position to validate. Column “A” on the spreadsheet is represented by
1.  Column “B” => 2

name:  (required) the name of the column. It’s necessary to nice error message if a validation rule fails 🙂

Validating the columns

fieldType: (optional) a string definining if the first row is a Header wich should be ignored in the validations. Allowed values:  “int”, “decimal”, “date”

pattern: (optional) define a expected pattern.

dateFormat: (optional) a string wich defines which character is separating de CSV, if the import file is a CSV.

isUnique: (optional) boolean. If it’s true,

notEmpty: (optional) a boolean wich, if true, will require al rows to have content

minLenght: (optional) an integer with the minimun characters allowed on the column.

maxLenght: (optional) an integer with the maximun characters allowed on the column.

allowedValues: (optional)  a string array with the vallues allowed on the column. Example: country codes.

allowedValuesCaseSensitive: (optional) a string array withe the values allowd on the column, CASE SENSITIVE

customValidationRule: (optional) the name of the predefined validation function. HOW TO DEFINE YOUR CUSTOM FUNCTIONS

Example

{
    "minColumns": 25,
    "maxColumns": 25,
    "fieldDelimiter": "|",
    "columnProperties": [
        {
            "name": "rnos",
            "fieldType": "int",
            "position": 1,
            "maxLength": 6,
            "minLength": 6,
            "notEmpty": true
        },
        {
            "name": "cuit_empleador",
            "position": 2,
            "customValidationRule": {
                "functionName": "validateCuitCuil"
            },
            "notEmpty": true
        },
        {
            "name": "cuil_titular",
            "position": 3,
            "customValidationRule": {
                "functionName": "validateCuitCuil"
            },
            "notEmpty": true
        },
        {
            "name": "parentesco",
            "position": 4,
            "allowedValues": ["00","01","02","03","04","05","06","07","08","09","0","1","2","3","4","5","6","7","8","9"],
            "notEmpty": true
        },
        {
            "name": "cuil",
            "position": 5,
            "customValidationRule": {
                "functionName": "validateCuitCuil"
            },
            "notEmpty": true,
            "isUnique": true
        },
        {
            "name": "documento_tipo",
            "position": 6,
            "allowedValues": ["01","02","03","04","05","06","07","08","09","DU","LE","LC","PA","CM","ET"],
            "notEmpty": true
        },
        {
            "name": "numero_docuento",
            "fieldType": "int",
            "position": 7,
            "maxLength": 8,
            "minLength": 7,
            "notEmpty": true
        },
        {
            "name": "nombre",
            "position": 8,
            "notEmpty": true
        },
        {
            "name": "sexo",
            "position": 9,
            "allowedValues": ["F","M"],
            "notEmpty": true
        },
        {
            "name": "estado_civil",
            "position": 10,
            "allowedValues": ["1","2","3","4","5","6","7"],
            "notEmpty": true
        },
        {
            "name": "fecha_nacimiento",
            "fieldType": "int",
            "position": 11,
            "notEmpty": true,
            "maxLength": 8,
            "minLength": 7
        },
        {
            "name": "nacionalidad",
            "fieldType": "int",
            "position": 12,
            "maxLength": 3,
            "notEmpty": true
        },
        {
            "name": "calle",
            "position": 13
        },
        {
            "name": "nro_puerta",
            "position": 14
        },
        {
            "name": "piso",
            "position": 15
        },
        {
            "name": "departamento",
            "position": 16
        },
        {
            "name": "localidad",
            "position": 17,
            "notEmpty": true
        },
        {
            "name": "codigo_postal",
            "position": 18,
            "notEmpty": true,
            "fieldType": "int"            
        },
        {
            "name": "provincia",
            "fieldType": "int",
            "position": 19,
            "notEmpty": true,
            "maxLength": 2
        },
        {
            "name": "domicilio_tipo",
            "position": 20,
            "notEmpty": true,
            "allowedValues": ["1","2"]
        },
        {
            "name": "telefono",
            "position": 21
        },
        {
            "name": "situacion_revista",
            "position": 22,
            "notEmpty": true,
            "allowedValues": ["0","10","11","12","13","50","51","52","53","99","98"]
        },
        {
            "name": "incapacidad",
            "position": 23,
            "notEmpty": true,
            "allowedValues": ["00","01","0","1"]
        },
        {
            "name": "tipo_beneficiario_titular",
            "position": 24,
            "notEmpty": true,
            "allowedValues": ["00","01","02","03","04","05","06","07","08","09","10","11","12"]
        },
        {
            "name": "fecha_alta_obrasocial",
            "position": 25,
            "notEmpty": true,
            "fieldType": "int",
            "maxLength": 8,
            "minLength": 7
        }
    ]
}