Skip to content

Instantly share code, notes, and snippets.

Custom rules on Respect/Validation

You may not know that [the most awesome validation engine for PHP][1] out there is [Respect/Validation][2], if you do, this is tailored for you! (I can do rimes, I expect you noted)

All rules on [Respect/Validation][2] are meant to be used togueter, composing a more complex validation rule that is closer to the domain of your application than the existing ones, let's try an example:

<?php

use Respect\Validation\Validator as v;
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
#=Navigating=
visit('/projects')
visit(post_comments_path(post))
#=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click_on('Button Value')
@dagron
dagron / gist:4c3e4ed1b5cfa15257c5
Created October 16, 2014 12:21
Angular contenteditable
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.directive('contenteditable', function() {
@dagron
dagron / react-d3.js
Last active August 29, 2015 14:11 — forked from couchand/react-d3.js
/** @jsx React.DOM */
// d3 chart function
// note that this is a higher-order function to
// allowing passing in the component properties/state
update = function(props) {
updateCircle = function(me) {
me
.attr("r", function(d) { return d.r; })
.attr("cx", function(d) { return 3 + d.r; })
@dagron
dagron / kefir.model.js
Last active August 29, 2015 14:27 — forked from a-s-o/kefir.model.js
Kefir model
/////////////
// Factory //
/////////////
Kefir.model = function (store, tx) {
if (typeof tx !== 'function') tx = x => x;
const getset = function kefir$model (update) {
if (arguments.length > 0) {
@dagron
dagron / 0x00000.bin
Created December 11, 2015 21:37 — forked from ajfisher/0x00000.bin
ESP8266 Transparent bridge to J5
@dagron
dagron / convert_doc.sh
Last active January 14, 2016 10:44
conver doc(x) and scan title to pdf
#!/bin/bash
for file_doc in `ls documents/*.doc*`; do
pdf_name=`echo $file_doc | sed -rn 's/\.(doc|docx)/.pdf/p'`
jpg_title=`echo $file_doc | sed -rn 's/\.(doc|docx)/.jpg/p'`
if ls $pdf_name &> /dev/null
then echo 'КОНВЕРТАЦИЯ В PDF: Такой файл существует' $pdf_name
else
loffice --headless --convert-to pdf $file_doc > /dev/null
if ls $jpg_title &> /dev/null
@dagron
dagron / TEACHER.csv
Created February 9, 2016 17:58
owncloud create users
Вася Пупкин 123456 super_vasia
#!/usr/bin/python3
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import os
txtparam = os.popen('ifconfig').read().encode('utf-8')
msg = MIMEText(txtparam, 'plain', 'utf-8')
msg['From'] = 'Mr. Robot <arsentiev.dan@>'