Skip to content

Commit

Permalink
Jh/bug fix string null validation (#279)
Browse files Browse the repository at this point in the history
* fix: use openssl legacy provider for node build

* fix: allow users to filter string field types by null

* fix: address new lint errors

* fix: update release please version
  • Loading branch information
jonnyhork authored Jun 12, 2024
1 parent 47547a3 commit d5cc9df
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-builder-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-builder-ui:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-common:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-data-view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-data-view:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-soql-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-soql-model:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion packages/soql-builder-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@lwc/lwc/no-async-operation": "off",
"@lwc/lwc/no-inner-html": "warn",
"@lwc/lwc/no-document-query": "warn",
"no-underscore-dangle": "off"
"no-underscore-dangle": "off",
"@typescript-eslint/no-unused-vars": "warn"
}
}
2 changes: 1 addition & 1 deletion packages/soql-builder-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"license": "BSD-3-Clause",
"main": "dist/",
"scripts": {
"build": "lwc-services build -w webpack.config.js -m production",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && lwc-services build -w webpack.config.js -m production",
"clean": "shx rm -rf package-lock.json && shx rm -rf dist && shx rm -rf node_modules",
"publish:lwc": "npm publish .",
"lint": "eslint ./src",
Expand Down
1 change: 1 addition & 0 deletions packages/soql-builder-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions packages/soql-model/src/validators/stringValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ describe('StringValidator should', () => {
it('return valid result for string in single quotes', () => {
expect(validator.validate("'foo'")).toEqual(validResult);
});

it('return valid result when user input is NULL or null', () => {
expect(validator.validate("'null'")).toEqual(validResult);
expect(validator.validate("'NULL'")).toEqual(validResult);
});

it('return not valid result for non-string value', () => {
expect(validator.validate('foo')).toEqual(notValidResult);
});

it('return not valid result for string ending in escaped quote', () => {
expect(validator.validate("'foo\\'")).toEqual(notValidResult);
});
Expand Down
9 changes: 5 additions & 4 deletions packages/soql-model/src/validators/stringValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { ValidateResult, Validator } from './validator';
export class StringValidator extends Validator {
public validate(input: string): ValidateResult {
const isValid =
input.length >= 2 &&
input.startsWith("'") &&
input.endsWith("'") &&
!this.isEscaped(input.substring(1, input.length - 1));
(input.length >= 2 &&
input.startsWith("'") &&
input.endsWith("'") &&
!this.isEscaped(input.substring(1, input.length - 1))) ||
input.toLowerCase() === 'null';
const message = isValid ? undefined : Messages.error_fieldInput_string;
return { isValid, message };
}
Expand Down

0 comments on commit d5cc9df

Please sign in to comment.